11.stylix/modules/gnome/nixos.nix
Jalil David Salamé Messina 7682713f6a
stylix: add 'stylix.enable' option (#244)
Add a 'stylix.enable' option to enable or disable all Stylix modules in
order to resolve issues similar to [2].

To align with the default 'lib.mkEnableOption' [1] behavior,
'stylix.enable' defaults to 'false'.

BREAKING CHANGE: Stylix is disabled by default. To enable it, use:

    stylix.enable = true;

[1]: https://github.com/NixOS/nixpkgs/blob/23.11/lib/options.nix#L91-L105
[2]: https://github.com/danth/stylix/issues/216

Co-authored-by: Daniel Thwaites <danthwaites30@btinternet.com>
Co-authored-by: Jalil David Salamé Messina <jalil.salame@gmail.com>
Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
2024-06-10 11:52:47 +02:00

50 lines
1.9 KiB
Nix

{ lib, pkgs, config, ... }@args:
let
theme = import ./theme.nix args;
in {
options.stylix.targets.gnome.enable =
config.lib.stylix.mkEnableTarget "GNOME and GDM" true;
config = lib.mkIf (
config.stylix.enable
&& config.stylix.targets.gnome.enable
&& config.services.xserver.desktopManager.gnome.enable
) {
# As Stylix is controlling the wallpaper, there is no need for this
# pack of default wallpapers to be installed.
# If you want to use one, you can set stylix.image to something like
# "${pkgs.gnome.gnome-backgrounds}/path/to/your/preferred/background"
# which will then download the pack regardless of its exclusion below.
environment.gnome.excludePackages = [ pkgs.gnome.gnome-backgrounds ];
nixpkgs.overlays = [(self: super: {
gnome = super.gnome.overrideScope (gnomeSelf: gnomeSuper: {
gnome-shell = gnomeSuper.gnome-shell.overrideAttrs (oldAttrs: {
# Themes are usually applied via an extension, but extensions are
# not available on the login screen. The only way to change the
# theme there is by replacing the default.
postFixup = (oldAttrs.postFixup or "") + ''
cp ${theme}/share/gnome-shell/gnome-shell-theme.gresource \
$out/share/gnome-shell/gnome-shell-theme.gresource
'';
patches = (oldAttrs.patches or []) ++ [
./shell_remove_dark_mode.patch
];
});
});
})];
# Cursor settings are usually applied via Home Manager,
# but the login screen uses a separate database.
environment.systemPackages = [ config.stylix.cursor.package ];
programs.dconf.profiles.gdm.databases = [{
lockAll = true;
settings."org/gnome/desktop/interface" = {
cursor-theme = config.stylix.cursor.name;
cursor-size = lib.gvariant.mkInt32 config.stylix.cursor.size;
};
}];
};
}