mirror of
https://github.com/nix-community/home-manager
synced 2024-11-16 08:09:45 +01:00
36a53d9f26
This process was automated by [my fork of `nix-doc-munge`]. All conversions were automatically checked to produce the same DocBook result when converted back, modulo minor typographical/formatting differences on the acceptable-to-desirable spectrum. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ {} + $ ./format [my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
97 lines
2.7 KiB
Nix
97 lines
2.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.fonts.fontconfig;
|
|
|
|
profileDirectory = config.home.profileDirectory;
|
|
|
|
in {
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
imports = [
|
|
(mkRenamedOptionModule [ "fonts" "fontconfig" "enableProfileFonts" ] [
|
|
"fonts"
|
|
"fontconfig"
|
|
"enable"
|
|
])
|
|
];
|
|
|
|
options = {
|
|
fonts.fontconfig = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Whether to enable fontconfig configuration. This will, for
|
|
example, allow fontconfig to discover fonts and
|
|
configurations installed through
|
|
{var}`home.packages` and
|
|
{command}`nix-env`.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [
|
|
# Make sure that buildEnv creates a real directory path so that we avoid
|
|
# trying to write to a read-only location.
|
|
(pkgs.runCommandLocal "dummy-fc-dir1" { } "mkdir -p $out/lib/fontconfig")
|
|
(pkgs.runCommandLocal "dummy-fc-dir2" { } "mkdir -p $out/lib/fontconfig")
|
|
];
|
|
|
|
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>
|
|
<dir>$out/lib/X11/fonts</dir>
|
|
<dir>$out/share/fonts</dir>
|
|
<cachedir>$out/lib/fontconfig/cache</cachedir>
|
|
</fontconfig>
|
|
EOF
|
|
|
|
${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
|
|
|
|
# Remove the fontconfig directory if no files were available.
|
|
if [[ -d $out/lib/fontconfig ]] ; then
|
|
rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig
|
|
fi
|
|
'';
|
|
|
|
xdg.configFile = {
|
|
"fontconfig/conf.d/10-hm-fonts.conf".text = ''
|
|
<?xml version='1.0'?>
|
|
|
|
<!-- Generated by Home Manager. -->
|
|
|
|
<!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'>
|
|
<fontconfig>
|
|
<description>Add fonts in the Nix user profile</description>
|
|
|
|
<include ignore_missing="yes">${config.home.path}/etc/fonts/conf.d</include>
|
|
<include ignore_missing="yes">${config.home.path}/etc/fonts/fonts.conf</include>
|
|
|
|
<dir>${config.home.path}/lib/X11/fonts</dir>
|
|
<dir>${config.home.path}/share/fonts</dir>
|
|
<dir>${profileDirectory}/lib/X11/fonts</dir>
|
|
<dir>${profileDirectory}/share/fonts</dir>
|
|
|
|
<cachedir>${config.home.path}/lib/fontconfig/cache</cachedir>
|
|
</fontconfig>
|
|
'';
|
|
};
|
|
};
|
|
}
|