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
|
|
|
|
|
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-08-31 18:40:34 +01:00
|
|
|
font_regexp='.*\.\(ttf\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
|
|
|
|
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"
|
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:35:13 +01:00
|
|
|
};
|
2013-06-27 12:12:45 +01:00
|
|
|
};
|
|
|
|
|
2020-09-01 15:35:13 +01:00
|
|
|
config = mkIf config.fonts.fontDir.enable {
|
2013-06-27 12:12:45 +01:00
|
|
|
|
2020-09-01 09:38:59 +01:00
|
|
|
# This is enough to make a symlink because the xserver
|
|
|
|
# module already links all /share/X11 paths.
|
2013-06-27 12:12:45 +01:00
|
|
|
environment.systemPackages = [ x11Fonts ];
|
|
|
|
|
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
|
|
|
}
|