stylix icon indicating copy to clipboard operation
stylix copied to clipboard

treewide: enable DConf if used in HM module

Open brckd opened this issue 9 months ago • 7 comments

The GTK module for NixOS enables DConf in order for the Home Manager module to take effect.

https://github.com/nix-community/stylix/blob/4a8718e5a14faeef3e57ededb4efb88b0deed329/modules/gtk/nixos.nix#L8-L9

The same should be done for the eog and gnome-text-editor targets, which contain DConf settings, but have no matching NixOS module.

https://github.com/nix-community/stylix/blob/4a8718e5a14faeef3e57ededb4efb88b0deed329/modules/eog/hm.nix#L8-L11

https://github.com/nix-community/stylix/blob/4a8718e5a14faeef3e57ededb4efb88b0deed329/modules/gnome-text-editor/hm.nix#L10

brckd avatar Mar 11 '25 17:03 brckd

The GTK module for NixOS enables DConf in order for the Home Manager module to take effect.

https://github.com/nix-community/stylix/blob/4a8718e5a14faeef3e57ededb4efb88b0deed329/modules/gtk/nixos.nix#L8-L9

The same should be done for the eog and gnome-text-editor targets, which contain DConf settings, but have no matching NixOS module.

https://github.com/nix-community/stylix/blob/4a8718e5a14faeef3e57ededb4efb88b0deed329/modules/eog/hm.nix#L8-L11

https://github.com/nix-community/stylix/blob/4a8718e5a14faeef3e57ededb4efb88b0deed329/modules/gnome-text-editor/hm.nix#L10

Do you mean that the Home Manager modules should programs.dconf.enable = true;? AFAIK, Home Manager is unable to install this system setting. The dconf.settings Home Manager option might be useful.

If you mean that we should add corresponding NixOS modules containing programs.dconf.enable = true;, then they should only do that when detecting that the corresponding Home Manager module is enabled. Although, I am unsure whether this detection is possible or how easy it would be.

trueNAHO avatar Mar 11 '25 22:03 trueNAHO

If you mean that we should add corresponding NixOS modules containing programs.dconf.enable = true;, then they should only do that when detecting that the corresponding Home Manager module is enabled. Although, I am unsure whether this detection is possible or how easy it would be.

Yes, this is what I meant. However, the NixOS module for GTK enables DConf only if that module is enabled, regardless of the state of the HM module. I'd argue we could do the same for the sake of consistency.

brckd avatar Mar 12 '25 06:03 brckd

I would argue for removing the GTK one, or replacing it with a warning when possible (based on osConfig within integrated Home Manager).

We don't usually enable programs on behalf of the user. (This code is a relic from the early days of Stylix.)

danth avatar Mar 13 '25 18:03 danth

Sure, that sounds like a viable option! The purpose of this PR was to create consistency, so I'm open to going the other way around.

brckd avatar Mar 13 '25 18:03 brckd

Hi there,

I' m having troubles on Hyprland. I didn' t find a way to fix it. Here is a summary:

Config

System: NixOS 25.05
DE/WM: Hyprland (not GNOME)
Home Manager

Changes

flake.nix:

stylix = {
  url = "github:danth/stylix/release-25.05";
  inputs.nixpkgs.follows = "nixpkgs";
};
...
  outputs =
    inputs @ { self
    , nixpkgs
    , home-manager
    , stylix
    , ...
    }: {
...
          modules = [
            ./hosts/phantec

            home-manager.nixosModules.home-manager
            {
              home-manager.useGlobalPkgs = true;
              home-manager.useUserPackages = true;
              home-manager.backupFileExtension = "backup";
              home-manager.extraSpecialArgs = inputs;
              home-manager.users.ph = import ./home;
            }

            stylix.homeModules.stylix
          ];
        };
...

stylix.nix:

{ pkgs, ... }:
{
  stylix = {
    enable = true;

    targets.gnome-text-editor.enable = false;
    targets.gnome-shell.enable = false;

    base16Scheme = "${pkgs.base16-schemes}/share/themes/nord.yaml";
    image = ./assets/nord-nixos.png;

    icons = {
      enable = true;
      package = pkgs.papirus-icon-theme;
      dark = "Papirus-Dark";
    };

    cursor = {
      package = pkgs.bibata-cursors;
      name = "Bibata-Modern-Ice";
      size = 24;
    };

    fonts = {
      sansSerif = { package = pkgs.noto-fonts; name = "Noto Sans"; };
      serif = { package = pkgs.noto-fonts; name = "Noto Serif"; };
      monospace = { package = pkgs.nerd-fonts.jetbrains-mono; name = "JetBrainsMono Nerd Font"; };
    };

    polarity = "dark";
  };
}

Error

nixos-config on  master [$+]
➜ sudo nixos-rebuild switch --flake .#phantec
[sudo] Mot de passe de ph :
warning: Git tree '/home/ph/nixos-config' is dirty
error:
       … while calling the 'seq' builtin
         at /nix/store/24qw2z8xgh1zd36vm52ackgzj84qqq9b-source/lib/modules.nix:359:18:
          358|         options = checked options;
          359|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          360|         _module = checked (config._module);

       … while calling the 'throw' builtin
         at /nix/store/24qw2z8xgh1zd36vm52ackgzj84qqq9b-source/lib/modules.nix:331:13:
          330|           else
          331|             throw baseMsg
             |             ^
          332|         else

       error: The option `dconf' does not exist. Definition values:
       - In `/nix/store/p4v5krrrz14kygkvhj5y6b1pk3r0c3sg-source/modules/gnome-text-editor/hm.nix':
           {
             _type = "if";
             condition = false;
             content = {
               settings = {
           ...

What I tried

  • Added programs.dconf.enable = true; in Home Manager config → error persists.

  • Imported Home Manager’s dconf module directly:

imports = [ "${home-manager}/modules/programs/dconf.nix" ];

→ error persists.

  • dconf enabled system wide → error persists.

Expectation

Since I’m not using GNOME (Hyprland only), I would expect Stylix to not require dconf / GNOME modules. I even explicitly disabled targets.gnome-text-editor and targets.gnome-shell, but Stylix still tries to evaluate them.

Questions

Am I missing something?

bourdeau avatar Sep 11 '25 06:09 bourdeau

@bourdeau It looks like you're importing Stylix's Home Manager module into NixOS, rather than Home Manager. Try replacing stylix.homeModules.stylix in your flake.nix with stylix.nixosModules.stylix. This should automatically set up Stylix in Home Manager as well.

danth avatar Sep 12 '25 19:09 danth

@danth Thanks a lot for your answer. You are right, I did' t pay attention. I will give it a shot tomorrow and keep you updated.

bourdeau avatar Sep 12 '25 20:09 bourdeau