nixpkgs-suyu/pkgs/desktops/gnome/nixos/gsettings-overrides/default.nix
Jan Tojnar 9e99c0195d gnome.nixos-gsettings-overrides: Ensure the settings are not overwritten
1d4bddaed5
started copying override files from packages into the schema for compilation.
`gsettings-desktop-schemas` package contains `remove-backgrounds.gschema.override`
which is later in the alphabet than `nixos-defaults.gschema.override`
so it would take precedence over the values from the GNOME NixOS module,
causing the background to not be set, among other things.

Let’s rename the override file coming from the module to be applied last.
2022-10-21 11:49:58 +02:00

55 lines
1.5 KiB
Nix

{ lib
, runCommand
, gsettings-desktop-schemas
, gnome-shell
, glib
, gnome-flashback
, nixos-artwork
, nixos-background-light ? nixos-artwork.wallpapers.simple-blue
, nixos-background-dark ? nixos-artwork.wallpapers.simple-dark-gray
, extraGSettingsOverrides ? ""
, extraGSettingsOverridePackages ? [ ]
, favoriteAppsOverride ? ""
, flashbackEnabled ? false
}:
let
inherit (lib) concatMapStringsSep;
gsettingsOverridePackages = [
gsettings-desktop-schemas
gnome-shell
] ++ lib.optionals flashbackEnabled [
gnome-flashback
] ++ extraGSettingsOverridePackages;
gsettingsOverrides = ''
[org.gnome.desktop.background]
picture-uri='file://${nixos-background-light.gnomeFilePath}'
picture-uri-dark='file://${nixos-background-dark.gnomeFilePath}'
[org.gnome.desktop.screensaver]
picture-uri='file://${nixos-background-dark.gnomeFilePath}'
${favoriteAppsOverride}
${extraGSettingsOverrides}
'';
in
runCommand "gnome-gsettings-overrides" { preferLocalBuild = true; } ''
data_dir="$out/share/gsettings-schemas/nixos-gsettings-overrides"
schema_dir="$data_dir/glib-2.0/schemas"
mkdir -p "$schema_dir"
${concatMapStringsSep "\n" (pkg: "cp -rf \"${glib.getSchemaPath pkg}\"/*.xml \"${glib.getSchemaPath pkg}\"/*.gschema.override \"$schema_dir\"") gsettingsOverridePackages}
chmod -R a+w "$data_dir"
cat - > "$schema_dir/zz-nixos-defaults.gschema.override" <<- EOF
${gsettingsOverrides}
EOF
${glib.dev}/bin/glib-compile-schemas --strict "$schema_dir"
''