mirror of
https://github.com/nix-community/home-manager
synced 2024-12-27 12:19:48 +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:
parent
939274281a
commit
b256e3a44f
6 changed files with 85 additions and 6 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
5
tests/modules/misc/fontconfig/default.nix
Normal file
5
tests/modules/misc/fontconfig/default.nix
Normal 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;
|
||||
}
|
15
tests/modules/misc/fontconfig/multiple-font-packages.nix
Normal file
15
tests/modules/misc/fontconfig/multiple-font-packages.nix
Normal 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
|
||||
'';
|
||||
};
|
||||
}
|
17
tests/modules/misc/fontconfig/no-font-package.nix
Normal file
17
tests/modules/misc/fontconfig/no-font-package.nix
Normal 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
|
||||
'';
|
||||
};
|
||||
}
|
15
tests/modules/misc/fontconfig/single-font-package.nix
Normal file
15
tests/modules/misc/fontconfig/single-font-package.nix
Normal 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
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue