1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

fontconfig: fix build error

This fixes a build error occurring when building a configuration
having fontconfig enabled and `home.packages` only containing one
package installing things to `/lib`.

Also adds a number of test cases to verify the fontconfig cache
generation functionality.

Fixes #703
This commit is contained in:
Robert Helgesson 2019-05-06 00:27:25 +02:00
parent 939274281a
commit b256e3a44f
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
6 changed files with 85 additions and 6 deletions

View file

@ -36,10 +36,29 @@ in
};
config = mkIf cfg.enable {
home.extraProfileCommands = ''
export FONTCONFIG_FILE=$(pwd)/fonts.conf
# 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";
})
cat > $FONTCONFIG_FILE << EOF
(pkgs.writeTextFile {
name = "hm-dummy2";
destination = "/lib/fontconfig/hm-dummy2";
text = "dummy";
})
];
home.extraProfileCommands = ''
if [[ -d $out/lib/X11/fonts || -d $out/share/fonts ]]; then
export FONTCONFIG_FILE="$(pwd)/fonts.conf"
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
unset FONTCONFIG_FILE
rm "$FONTCONFIG_FILE"
unset FONTCONFIG_FILE
fi
# Remove hacky dummy files.
rm $out/lib/fontconfig/hm-dummy?
rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig
'';
xdg.configFile = {

View file

@ -35,6 +35,7 @@ import nmt {
// import ./modules/systemd
)
// import ./modules/home-environment
// import ./modules/misc/fontconfig
// import ./modules/programs/bash
// import ./modules/programs/ssh
// import ./modules/programs/tmux

View file

@ -0,0 +1,5 @@
{
fontconfig-no-font-package = ./no-font-package.nix;
fontconfig-single-font-package = ./single-font-package.nix;
fontconfig-multiple-font-packages = ./multiple-font-packages.nix;
}

View file

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
home.packages = [ pkgs.comic-relief pkgs.unifont ];
fonts.fontconfig.enable = true;
nmt.script = ''
assertDirectoryNotEmpty home-path/lib/fontconfig/cache
'';
};
}

View file

@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
home.packages = [
# Look, no font!
];
fonts.fontconfig.enable = true;
nmt.script = ''
assertPathNotExists home-path/lib/fontconfig/cache
'';
};
}

View file

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
home.packages = [ pkgs.comic-relief ];
fonts.fontconfig.enable = true;
nmt.script = ''
assertDirectoryNotEmpty home-path/lib/fontconfig/cache
'';
};
}