diff options
Diffstat (limited to 'modules/misc/fontconfig.nix')
-rw-r--r-- | modules/misc/fontconfig.nix | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix index 9f3def775f5..8dbcce53c22 100644 --- a/modules/misc/fontconfig.nix +++ b/modules/misc/fontconfig.nix @@ -36,10 +36,29 @@ in }; config = mkIf cfg.enable { + # Create two dummy files in /lib/fontconfig to make sure that + # buildEnv creates a real directory path. These files are removed + # in home.extraProfileCommands below so the packages will not + # become "runtime" dependencies. + home.packages = [ + (pkgs.writeTextFile { + name = "hm-dummy1"; + destination = "/lib/fontconfig/hm-dummy1"; + text = "dummy"; + }) + + (pkgs.writeTextFile { + name = "hm-dummy2"; + destination = "/lib/fontconfig/hm-dummy2"; + text = "dummy"; + }) + ]; + home.extraProfileCommands = '' - export FONTCONFIG_FILE=$(pwd)/fonts.conf + if [[ -d $out/lib/X11/fonts || -d $out/share/fonts ]]; then + export FONTCONFIG_FILE="$(pwd)/fonts.conf" - cat > $FONTCONFIG_FILE << EOF + cat > $FONTCONFIG_FILE << EOF <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig> @@ -49,10 +68,17 @@ in </fontconfig> EOF - ${getBin pkgs.fontconfig}/bin/fc-cache -f - rm -f $out/lib/fontconfig/cache/CACHEDIR.TAG + ${getBin pkgs.fontconfig}/bin/fc-cache -f + rm -f $out/lib/fontconfig/cache/CACHEDIR.TAG + rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig/cache + + rm "$FONTCONFIG_FILE" + unset FONTCONFIG_FILE + fi - unset FONTCONFIG_FILE + # Remove hacky dummy files. + rm $out/lib/fontconfig/hm-dummy? + rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig ''; xdg.configFile = { |