diff --git a/modules/gnome/hm.nix b/modules/gnome/hm.nix index 717ec29..a5f2ae2 100644 --- a/modules/gnome/hm.nix +++ b/modules/gnome/hm.nix @@ -22,6 +22,18 @@ with lib; if config.stylix.polarity == "dark" then "prefer-dark" else "default"; + + "org/gnome/shell/extensions/user-theme".name = "Stylix"; + }; + + xdg.dataFile."themes/Stylix/gnome-shell/gnome-shell.css" = { + source = + let theme = import ./theme.nix { inherit pkgs config; }; + in "${theme}/share/gnome-shell/gnome-shell.css"; + onChange = '' + gnome-extensions disable user-theme@gnome-shell-extensions.gcampax.github.com + gnome-extensions enable user-theme@gnome-shell-extensions.gcampax.github.com + ''; }; }; } diff --git a/modules/gnome/nixos.nix b/modules/gnome/nixos.nix index 973034c..84376ee 100644 --- a/modules/gnome/nixos.nix +++ b/modules/gnome/nixos.nix @@ -17,17 +17,13 @@ with lib; nixpkgs.overlays = [(self: super: { gnome = super.gnome.overrideScope' (gnomeSelf: gnomeSuper: { gnome-shell = gnomeSuper.gnome-shell.overrideAttrs (oldAttrs: { - postPatch = let - colors = config.lib.stylix.colors { - template = builtins.readFile ./colors.mustache; - extension = "scss"; - }; - in (oldAttrs.postPatch or "") + '' - rm data/theme/gnome-shell-sass/{_colors.scss,_palette.scss} - cp ${colors} data/theme/gnome-shell-sass/_colors.scss - ''; + postFixup = + let theme = import ./theme.nix { inherit pkgs config; }; + in '' + cp ${theme}/share/gnome-shell/gnome-shell-theme.gresource \ + $out/share/gnome-shell/gnome-shell-theme.gresource + ''; patches = (oldAttrs.patches or []) ++ [ - ./shell_colors.patch ./shell_remove_dark_mode.patch ]; }); diff --git a/modules/gnome/theme.nix b/modules/gnome/theme.nix new file mode 100644 index 0000000..0c0b97d --- /dev/null +++ b/modules/gnome/theme.nix @@ -0,0 +1,34 @@ +{ pkgs, config }: + +let + colors = config.lib.stylix.colors { + template = builtins.readFile ./colors.mustache; + extension = "scss"; + }; + +in pkgs.stdenv.mkDerivation { + name = "stylix-gnome-shell-theme"; + + src = pkgs.fetchurl { + url = "mirror://gnome/sources/gnome-shell/43/gnome-shell-43.2.tar.xz"; + sha256 = "52/UvpNCQQ7p+9zday2Bxv8GDnyMxaDxyuanq6JdGGA="; + }; + + patches = [ ./shell_colors.patch ]; + postPatch = '' + rm data/theme/gnome-shell-sass/{_colors.scss,_palette.scss} + cp ${colors} data/theme/gnome-shell-sass/_colors.scss + ''; + + nativeBuildInputs = with pkgs; [ sass glib.dev ]; + buildPhase = '' + sass data/theme/gnome-shell.scss >data/theme/gnome-shell.css + glib-compile-resources --sourcedir=data/theme data/gnome-shell-theme.gresource.xml + ''; + + installPhase = '' + mkdir -p $out/share/gnome-shell + mv data/theme/gnome-shell.css $out/share/gnome-shell/gnome-shell.css + mv data/gnome-shell-theme.gresource $out/share/gnome-shell/gnome-shell-theme.gresource + ''; +}