Build gresource within GNOME shell derivation ♻️

This commit is contained in:
Daniel Thwaites 2023-01-06 23:46:06 +00:00
parent 43a0330a31
commit 34a852baee
No known key found for this signature in database
GPG key ID: D8AFC4BF05670F9D

View file

@ -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;
@ -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 ];
});
});
})];