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