Merge pull request #192969 from jtojnar/extra-gsettings-strict

GNOME/Cinnamon/Pantheon: Clean up GSettings overrides and make strict
This commit is contained in:
Jan Tojnar 2022-10-04 00:59:08 +02:00 committed by GitHub
commit e14d1e1bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 89 additions and 58 deletions

View File

@ -22,42 +22,14 @@ let
favorite-apps=[ 'org.gnome.Epiphany.desktop', 'org.gnome.Geary.desktop', 'org.gnome.Calendar.desktop', 'org.gnome.Music.desktop', 'org.gnome.Photos.desktop', 'org.gnome.Nautilus.desktop' ]
'';
nixos-background-ligtht = pkgs.nixos-artwork.wallpapers.simple-blue;
nixos-background-light = pkgs.nixos-artwork.wallpapers.simple-blue;
nixos-background-dark = pkgs.nixos-artwork.wallpapers.simple-dark-gray;
nixos-gsettings-desktop-schemas = let
defaultPackages = with pkgs; [ gsettings-desktop-schemas gnome.gnome-shell ];
in
pkgs.runCommand "nixos-gsettings-desktop-schemas" { preferLocalBuild = true; }
''
mkdir -p $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
${concatMapStrings
(pkg: "cp -rf ${pkg}/share/gsettings-schemas/*/glib-2.0/schemas/*.xml $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas\n")
(defaultPackages ++ cfg.extraGSettingsOverridePackages)}
cp -f ${pkgs.gnome.gnome-shell}/share/gsettings-schemas/*/glib-2.0/schemas/*.gschema.override $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
${optionalString flashbackEnabled ''
cp -f ${pkgs.gnome.gnome-flashback}/share/gsettings-schemas/*/glib-2.0/schemas/*.gschema.override $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
''}
chmod -R a+w $out/share/gsettings-schemas/nixos-gsettings-overrides
cat - > $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas/nixos-defaults.gschema.override <<- EOF
[org.gnome.desktop.background]
picture-uri='file://${nixos-background-ligtht.gnomeFilePath}'
picture-uri-dark='file://${nixos-background-dark.gnomeFilePath}'
[org.gnome.desktop.screensaver]
picture-uri='file://${nixos-background-dark.gnomeFilePath}'
${cfg.favoriteAppsOverride}
${cfg.extraGSettingsOverrides}
EOF
${pkgs.glib.dev}/bin/glib-compile-schemas $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas/
'';
# TODO: Having https://github.com/NixOS/nixpkgs/issues/54150 would supersede this
nixos-gsettings-desktop-schemas = pkgs.gnome.nixos-gsettings-overrides.override {
inherit (cfg) extraGSettingsOverrides extraGSettingsOverridePackages favoriteAppsOverride;
inherit flashbackEnabled nixos-background-dark nixos-background-light;
};
nixos-background-info = pkgs.writeTextFile rec {
name = "nixos-background-info";
@ -67,7 +39,7 @@ let
<wallpapers>
<wallpaper deleted="false">
<name>Blobs</name>
<filename>${nixos-background-ligtht.gnomeFilePath}</filename>
<filename>${nixos-background-light.gnomeFilePath}</filename>
<filename-dark>${nixos-background-dark.gnomeFilePath}</filename-dark>
<options>zoom</options>
<shade_type>solid</shade_type>

View File

@ -20,6 +20,8 @@
let
inherit (lib) concatMapStringsSep;
gsettingsOverridePackages = [
# from
mint-artwork
@ -38,22 +40,21 @@ let
in
with lib;
# TODO: Having https://github.com/NixOS/nixpkgs/issues/54150 would supersede this
runCommand "cinnamon-gsettings-overrides" { }
runCommand "cinnamon-gsettings-overrides" { preferLocalBuild = true; }
''
schema_dir=$out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
data_dir="$out/share/gsettings-schemas/nixos-gsettings-overrides"
schema_dir="$data_dir/glib-2.0/schemas"
mkdir -p $schema_dir
mkdir -p "$schema_dir"
${concatMapStrings (pkg: "cp -rf ${glib.getSchemaPath pkg}/*.xml ${glib.getSchemaPath pkg}/*.gschema.override $schema_dir\n") gsettingsOverridePackages}
${concatMapStringsSep "\n" (pkg: "cp -rf \"${glib.getSchemaPath pkg}\"/*.xml \"${glib.getSchemaPath pkg}\"/*.gschema.override \"$schema_dir\"") gsettingsOverridePackages}
chmod -R a+w $out/share/gsettings-schemas/nixos-gsettings-overrides
chmod -R a+w "$data_dir"
cat - > $schema_dir/nixos-defaults.gschema.override <<- EOF
cat - > "$schema_dir/nixos-defaults.gschema.override" <<- EOF
${extraGSettingsOverrides}
EOF
${glib.dev}/bin/glib-compile-schemas $schema_dir
${glib.dev}/bin/glib-compile-schemas --strict "$schema_dir"
''

View File

@ -123,6 +123,8 @@ lib.makeScope pkgs.newScope (self: with self; {
withGnome = true;
};
nixos-gsettings-overrides = callPackage ./nixos/gsettings-overrides { };
rygel = callPackage ./core/rygel { };
simple-scan = callPackage ./core/simple-scan { };

View File

@ -0,0 +1,55 @@
{ 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/nixos-defaults.gschema.override" <<- EOF
${gsettingsOverrides}
EOF
${glib.dev}/bin/glib-compile-schemas --strict "$schema_dir"
''

View File

@ -10,11 +10,13 @@
, elementary-dock
, gsettings-desktop-schemas
, extraGSettingsOverrides ? ""
, extraGSettingsOverridePackages ? []
, extraGSettingsOverridePackages ? [ ]
}:
let
inherit (lib) concatMapStringsSep;
gsettingsOverridePackages = [
elementary-dock
gnome-settings-daemon
@ -27,25 +29,24 @@ let
in
with lib;
# TODO: Having https://github.com/NixOS/nixpkgs/issues/54150 would supersede this
runCommand "elementary-gsettings-desktop-schemas" {}
runCommand "elementary-gsettings-desktop-schemas" { preferLocalBuild = true; }
''
schema_dir=$out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
data_dir="$out/share/gsettings-schemas/nixos-gsettings-overrides"
schema_dir="$data_dir/glib-2.0/schemas"
mkdir -p $schema_dir
mkdir -p "$schema_dir"
cp -rf "${glib.getSchemaPath gala}"/*.gschema.override "$schema_dir"
cp -rf ${glib.getSchemaPath gala}/*.gschema.override $schema_dir
${concatMapStringsSep "\n" (pkg: "cp -rf \"${glib.getSchemaPath pkg}\"/*.xml \"$schema_dir\"") gsettingsOverridePackages}
${concatMapStrings (pkg: "cp -rf ${glib.getSchemaPath pkg}/*.xml $schema_dir\n") gsettingsOverridePackages}
chmod -R a+w "$data_dir"
cp "${glib.getSchemaPath elementary-default-settings}"/* "$schema_dir"
chmod -R a+w $out/share/gsettings-schemas/nixos-gsettings-overrides
cp ${glib.getSchemaPath elementary-default-settings}/* $schema_dir
cat - > "$schema_dir/nixos-defaults.gschema.override" <<- EOF
${extraGSettingsOverrides}
EOF
cat - > $schema_dir/nixos-defaults.gschema.override <<- EOF
${extraGSettingsOverrides}
EOF
${glib.dev}/bin/glib-compile-schemas $schema_dir
${glib.dev}/bin/glib-compile-schemas $schema_dir
''