From 3e7e6ab84a5a4facdbeea8941af9df471d66c839 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 25 Feb 2022 01:08:47 +0200 Subject: [PATCH 1/2] buildFHSUserEnv{Chroot,Bubblewrap}: link gsettings-schemas to the FHS location We shouldn't need to use wrapGAppsHook in expressions that use this builder. --- .../special/fhs-environments.section.md | 2 ++ .../build-fhs-userenv-bubblewrap/env.nix | 26 +++++++++++++++++++ pkgs/build-support/build-fhs-userenv/env.nix | 26 +++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/doc/builders/special/fhs-environments.section.md b/doc/builders/special/fhs-environments.section.md index 43dc99b7c18f..cacad261e28f 100644 --- a/doc/builders/special/fhs-environments.section.md +++ b/doc/builders/special/fhs-environments.section.md @@ -45,3 +45,5 @@ One can create a simple environment using a `shell.nix` like that: ``` Running `nix-shell` would then drop you into a shell with these libraries and binaries available. You can use this to run closed-source applications which expect FHS structure without hassles: simply change `runScript` to the application path, e.g. `./bin/start.sh` -- relative paths are supported. + +Additionally, the FHS builder links all relocated gsettings-schemas (the glib setup-hook moves them to `share/gsettings-schemas/${name}/glib-2.0/schemas`) to their standard FHS location. This means you don't need to wrap binaries with `wrapGAppsHook`. diff --git a/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix b/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix index 0051961d9f17..c2f3ade6457b 100644 --- a/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix +++ b/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix @@ -93,6 +93,32 @@ let paths = [ etcPkg ldconfig ] ++ basePkgs ++ targetPaths; extraOutputsToInstall = [ "out" "lib" "bin" ] ++ extraOutputsToInstall; ignoreCollisions = true; + postBuild = '' + if [[ -d $out/share/gsettings-schemas/ ]]; then + # Recreate the standard schemas directory if its a symlink to make it writable + if [[ -L $out/share/glib-2.0 ]]; then + ln -s $(readlink $out/share/glib-2.0) $out/share/glib-2.0.old + rm -rf $out/share/glib-2.0 + fi + + mkdir -p $out/share/glib-2.0/schemas + + # symlink any schema files or overrides to the standard schema directory + if [[ -e $out/share/glib-2.0.old/schemas ]]; then + ln -fs $out/share/glib-2.0.old/schemas/*.xml $out/share/glib-2.0/schemas + ln -fs $out/share/glib-2.0.old/schemas/*.gsettings-schemas.override $out/share/glib-2.0/schemas + fi + + for d in $out/share/gsettings-schemas/*; do + # Force symlink, in case there are duplicates + ln -fs $d/glib-2.0/schemas/*.xml $out/share/glib-2.0/schemas + ln -fs $d/glib-2.0/schemas/*.gschema.override $out/share/glib-2.0/schemas + done + + # and compile them + ${pkgs.glib.dev}/bin/glib-compile-schemas $out/share/glib-2.0/schemas + fi + ''; }; staticUsrProfileMulti = buildEnv { diff --git a/pkgs/build-support/build-fhs-userenv/env.nix b/pkgs/build-support/build-fhs-userenv/env.nix index 44c8adb06e18..bd3a2d5e12dd 100644 --- a/pkgs/build-support/build-fhs-userenv/env.nix +++ b/pkgs/build-support/build-fhs-userenv/env.nix @@ -134,6 +134,32 @@ let paths = [ etcPkg ] ++ basePkgs ++ targetPaths; extraOutputsToInstall = [ "out" "lib" "bin" ] ++ extraOutputsToInstall; ignoreCollisions = true; + postBuild = '' + if [[ -d $out/share/gsettings-schemas/ ]]; then + # Recreate the standard schemas directory if its a symlink to make it writable + if [[ -L $out/share/glib-2.0 ]]; then + ln -s $(readlink $out/share/glib-2.0) $out/share/glib-2.0.old + rm -rf $out/share/glib-2.0 + fi + + mkdir -p $out/share/glib-2.0/schemas + + # symlink any schema files or overrides to the standard schema directory + if [[ -e $out/share/glib-2.0.old/schemas ]]; then + ln -fs $out/share/glib-2.0.old/schemas/*.xml $out/share/glib-2.0/schemas + ln -fs $out/share/glib-2.0.old/schemas/*.gsettings-schemas.override $out/share/glib-2.0/schemas + fi + + for d in $out/share/gsettings-schemas/*; do + # Force symlink, in case there are duplicates + ln -fs $d/glib-2.0/schemas/*.xml $out/share/glib-2.0/schemas + ln -fs $d/glib-2.0/schemas/*.gschema.override $out/share/glib-2.0/schemas + done + + # and compile them + ${pkgs.glib.dev}/bin/glib-compile-schemas $out/share/glib-2.0/schemas + fi + ''; }; staticUsrProfileMulti = buildEnv { From 4330797dfb095d59f57bb65f04d4054a53089892 Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 3 Mar 2022 01:23:11 +0200 Subject: [PATCH 2/2] appimage: add gsettings-desktop-schemas, hicolor-icon-theme to the fhs --- pkgs/build-support/appimage/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/build-support/appimage/default.nix b/pkgs/build-support/appimage/default.nix index 9ceaab88946d..cc2b2f3ed3de 100644 --- a/pkgs/build-support/appimage/default.nix +++ b/pkgs/build-support/appimage/default.nix @@ -68,6 +68,8 @@ rec { xdg-utils iana-etc krb5 + gsettings-desktop-schemas + hicolor-icon-theme # dont show a gtk warning about hicolor not being installed ]; # list of libraries expected in an appimage environment: