Skip to content

Commit

Permalink
Build gresource within GNOME shell derivation ♻️
Browse files Browse the repository at this point in the history
  • Loading branch information
danth committed Jan 6, 2023
1 parent 43a0330 commit 34a852b
Showing 1 changed file with 10 additions and 35 deletions.
45 changes: 10 additions & 35 deletions modules/gnome/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,7 @@

with lib;

let
colors = config.lib.stylix.colors {
template = builtins.readFile ./colors.mustache;
extension = "scss";
};

theme = pkgs.stdenv.mkDerivation {
name = "stylix-gnome-shell";

src = pkgs.fetchurl {
url = "mirror://gnome/sources/gnome-shell/43/gnome-shell-43.2.tar.xz";
sha256 = "52/UvpNCQQ7p+9zday2Bxv8GDnyMxaDxyuanq6JdGGA=";
};

patches = [ ./shell.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
# cp data/theme/gnome-shell.css data/theme/gnome-shell-high-contrast.css
glib-compile-resources --sourcedir=data/theme data/gnome-shell-theme.gresource.xml
'';

installPhase = ''
mv data/gnome-shell-theme.gresource $out
'';
};

in {
{
options.stylix.targets.gnome.enable =
config.lib.stylix.mkEnableTarget "GNOME" config.services.xserver.desktopManager.gnome.enable;

Expand Down Expand Up @@ -65,9 +33,16 @@ in {
nixpkgs.overlays = [(self: super: {
gnome = super.gnome.overrideScope' (gnomeSelf: gnomeSuper: {
gnome-shell = gnomeSuper.gnome-shell.overrideAttrs (oldAttrs: {
postFixup = ''
cp ${theme} $out/share/gnome-shell/gnome-shell-theme.gresource
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
'';
patches = (oldAttrs.patches or []) ++ [ ./shell.patch ];
});
});
})];
Expand Down

0 comments on commit 34a852b

Please sign in to comment.