2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-06-27 12:12:45 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2013-06-27 12:12:45 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2020-09-02 02:59:58 +01:00
|
|
|
cfg = config.fonts.fontDir;
|
|
|
|
|
2018-11-08 10:59:03 +00:00
|
|
|
x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
|
2020-09-01 09:38:59 +01:00
|
|
|
mkdir -p "$out/share/X11/fonts"
|
2020-10-26 02:45:22 +00:00
|
|
|
font_regexp='.*\.\(ttf\|ttc\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
|
2020-08-31 18:40:34 +01:00
|
|
|
find ${toString config.fonts.fonts} -regex "$font_regexp" \
|
2020-09-01 09:38:59 +01:00
|
|
|
-exec ln -sf -t "$out/share/X11/fonts" '{}' \;
|
|
|
|
cd "$out/share/X11/fonts"
|
2020-09-02 02:59:58 +01:00
|
|
|
${optionalString cfg.decompressFonts ''
|
2020-09-01 15:38:06 +01:00
|
|
|
${pkgs.gzip}/bin/gunzip -f *.gz
|
|
|
|
''}
|
2016-05-25 18:10:16 +01:00
|
|
|
${pkgs.xorg.mkfontscale}/bin/mkfontscale
|
2020-08-30 21:39:27 +01:00
|
|
|
${pkgs.xorg.mkfontdir}/bin/mkfontdir
|
2016-05-25 18:10:16 +01:00
|
|
|
cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
|
|
|
|
'';
|
2013-06-27 12:12:45 +01:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
2020-09-01 15:35:13 +01:00
|
|
|
fonts.fontDir = {
|
2013-06-27 12:12:45 +01:00
|
|
|
|
2020-09-01 15:35:13 +01:00
|
|
|
enable = mkOption {
|
2020-04-27 08:04:07 +01:00
|
|
|
type = types.bool;
|
2013-06-27 12:12:45 +01:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to create a directory with links to all fonts in
|
2020-09-01 09:38:59 +01:00
|
|
|
<filename>/run/current-system/sw/share/X11/fonts</filename>.
|
2013-06-27 12:12:45 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-09-01 15:38:06 +01:00
|
|
|
decompressFonts = mkOption {
|
|
|
|
type = types.bool;
|
2020-09-02 02:59:58 +01:00
|
|
|
default = config.programs.xwayland.enable;
|
2020-09-01 15:38:06 +01:00
|
|
|
description = ''
|
|
|
|
Whether to decompress fonts in
|
|
|
|
<filename>/run/current-system/sw/share/X11/fonts</filename>.
|
|
|
|
'';
|
|
|
|
};
|
2013-06-27 12:12:45 +01:00
|
|
|
|
2020-09-01 15:35:13 +01:00
|
|
|
};
|
2013-06-27 12:12:45 +01:00
|
|
|
};
|
|
|
|
|
2020-09-02 02:59:58 +01:00
|
|
|
config = mkIf cfg.enable {
|
2013-06-27 12:12:45 +01:00
|
|
|
|
|
|
|
environment.systemPackages = [ x11Fonts ];
|
2021-10-06 07:52:39 +01:00
|
|
|
environment.pathsToLink = [ "/share/X11/fonts" ];
|
2013-06-27 12:12:45 +01:00
|
|
|
|
2020-09-01 09:38:59 +01:00
|
|
|
services.xserver.filesSection = ''
|
|
|
|
FontPath "${x11Fonts}/share/X11/fonts"
|
|
|
|
'';
|
2016-05-25 18:10:16 +01:00
|
|
|
|
2013-06-27 12:12:45 +01:00
|
|
|
};
|
|
|
|
|
2020-09-01 15:35:13 +01:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
|
|
|
|
];
|
|
|
|
|
2013-06-27 12:12:45 +01:00
|
|
|
}
|