2010-08-10 02:03:36 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2009-01-02 17:07:39 +01:00
|
|
|
|
|
|
|
###### interface
|
2010-08-10 02:03:36 +02:00
|
|
|
|
2009-01-02 17:07:39 +01:00
|
|
|
let
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
fonts = {
|
|
|
|
|
|
|
|
enableFontConfig = mkOption { # !!! should be enableFontconfig
|
|
|
|
default = true;
|
|
|
|
description = "
|
|
|
|
If enabled, a Fontconfig configuration file will be built
|
|
|
|
pointing to a set of default fonts. If you don't care about
|
|
|
|
running X11 applications or any other program that uses
|
|
|
|
Fontconfig, you can turn this option off and prevent a
|
|
|
|
dependency on all those fonts.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
2010-08-10 02:03:36 +02:00
|
|
|
# Should be moved elsewhere.
|
2009-01-02 17:07:39 +01:00
|
|
|
enableGhostscriptFonts = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether to add the fonts provided by Ghostscript (such as
|
|
|
|
various URW fonts and the ``Base-14'' Postscript fonts) to the
|
|
|
|
list of system fonts, making them available to X11
|
|
|
|
applications.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
enableFontDir = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
2011-09-14 20:20:50 +02:00
|
|
|
Whether to create a directory with links to all fonts in share -
|
|
|
|
so user can configure vncserver script one time (I mean per-user
|
2009-01-02 17:07:39 +01:00
|
|
|
vncserver, so global service is not a good solution).
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: find another name for it.
|
|
|
|
fonts = mkOption {
|
|
|
|
default = [
|
|
|
|
# - the user's .fonts directory
|
|
|
|
"~/.fonts"
|
|
|
|
# - the user's current profile
|
|
|
|
"~/.nix-profile/lib/X11/fonts"
|
|
|
|
"~/.nix-profile/share/fonts"
|
|
|
|
# - the default profile
|
2011-10-30 16:19:58 +01:00
|
|
|
"/nix/var/nix/profiles/default/lib/X11/fonts"
|
|
|
|
"/nix/var/nix/profiles/default/share/fonts"
|
2009-01-02 17:07:39 +01:00
|
|
|
];
|
|
|
|
description = "
|
|
|
|
List of primary font paths.
|
|
|
|
";
|
|
|
|
apply = list: list ++ [
|
|
|
|
# - a few statically built locations
|
|
|
|
pkgs.xorg.fontbhttf
|
|
|
|
pkgs.xorg.fontbhlucidatypewriter100dpi
|
|
|
|
pkgs.xorg.fontbhlucidatypewriter75dpi
|
|
|
|
pkgs.ttf_bitstream_vera
|
|
|
|
pkgs.freefont_ttf
|
2009-07-09 14:10:58 +02:00
|
|
|
pkgs.liberation_ttf
|
2009-01-02 17:07:39 +01:00
|
|
|
pkgs.xorg.fontbh100dpi
|
|
|
|
pkgs.xorg.fontmiscmisc
|
|
|
|
pkgs.xorg.fontcursormisc
|
|
|
|
]
|
2010-08-10 02:03:36 +02:00
|
|
|
++ optional config.fonts.enableCoreFonts pkgs.corefonts
|
|
|
|
++ optional config.fonts.enableGhostscriptFonts "${pkgs.ghostscript}/share/ghostscript/fonts"
|
2009-01-02 17:07:39 +01:00
|
|
|
++ config.fonts.extraFonts;
|
|
|
|
};
|
|
|
|
|
|
|
|
extraFonts = mkOption {
|
|
|
|
default = [];
|
2010-05-17 16:09:22 +02:00
|
|
|
example = [ pkgs.dejavu_fonts ];
|
2009-07-08 16:52:58 +02:00
|
|
|
description = ''
|
2010-05-17 16:09:22 +02:00
|
|
|
List of packages with additional fonts.
|
2009-07-08 16:52:58 +02:00
|
|
|
'';
|
2009-01-02 17:07:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enableCoreFonts = mkOption {
|
2009-07-08 16:52:58 +02:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to include Microsoft's proprietary Core Fonts. These fonts
|
|
|
|
are redistributable, but only verbatim, among other restrictions.
|
|
|
|
See <link xlink:href="http://corefonts.sourceforge.net/eula.htm"/>
|
|
|
|
for details.
|
|
|
|
'';
|
2009-01-02 17:07:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
let
|
2010-11-11 14:24:37 +01:00
|
|
|
inherit (pkgs) builderDefs;
|
2009-01-02 17:07:39 +01:00
|
|
|
inherit (pkgs.xorg) mkfontdir mkfontscale fontalias;
|
|
|
|
|
|
|
|
fontDirs = config.fonts.fonts;
|
|
|
|
|
|
|
|
|
|
|
|
localDefs = with builderDefs; builderDefs.passthru.function rec {
|
|
|
|
src = "";/* put a fetchurl here */
|
|
|
|
|
2010-11-11 14:24:37 +01:00
|
|
|
buildInputs = [mkfontdir mkfontscale];
|
2009-01-02 17:07:39 +01:00
|
|
|
configureFlags = [];
|
|
|
|
inherit fontDirs;
|
2009-05-20 01:51:13 +02:00
|
|
|
installPhase = fullDepEntry ("
|
2009-01-02 17:07:39 +01:00
|
|
|
list='';
|
|
|
|
for i in ${toString fontDirs} ; do
|
|
|
|
if [ -d \$i/ ]; then
|
|
|
|
list=\"\$list \$i\";
|
|
|
|
fi;
|
|
|
|
done
|
2011-05-28 21:58:43 +02:00
|
|
|
list=\$(find \$list -name fonts.dir -o -name '*.ttf' -o -name '*.otf');
|
2009-01-02 17:07:39 +01:00
|
|
|
fontDirs='';
|
|
|
|
for i in \$list ; do
|
|
|
|
fontDirs=\"\$fontDirs \$(dirname \$i)\";
|
|
|
|
done;
|
2011-09-14 20:20:50 +02:00
|
|
|
mkdir -p \$out/share/X11-fonts/;
|
2011-05-28 22:08:49 +02:00
|
|
|
find \$fontDirs -type f -o -type l | while read i; do
|
|
|
|
j=\"\${i##*/}\"
|
|
|
|
if ! test -e \"\$out/share/X11-fonts/\${j}\"; then
|
|
|
|
ln -s \"\$i\" \"\$out/share/X11-fonts/\${j}\";
|
2009-01-02 17:07:39 +01:00
|
|
|
fi;
|
|
|
|
done;
|
|
|
|
cd \$out/share/X11-fonts/
|
|
|
|
rm fonts.dir
|
|
|
|
rm fonts.scale
|
|
|
|
rm fonts.alias
|
|
|
|
mkfontdir
|
|
|
|
mkfontscale
|
|
|
|
cat \$( find ${fontalias}/ -name fonts.alias) >fonts.alias
|
|
|
|
") ["minInit" "addInputs"];
|
|
|
|
};
|
|
|
|
|
|
|
|
x11Fonts = with localDefs; stdenv.mkDerivation rec {
|
|
|
|
name = "X11-fonts";
|
|
|
|
builder = writeScript (name + "-builder")
|
2011-09-14 20:20:50 +02:00
|
|
|
(textClosure localDefs
|
2009-01-02 17:07:39 +01:00
|
|
|
[installPhase doForceShare doPropagate]);
|
|
|
|
meta = {
|
|
|
|
description = "
|
|
|
|
Directory to contain all X11 fonts requested.
|
|
|
|
";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2009-05-28 14:06:54 +02:00
|
|
|
require = [options];
|
|
|
|
|
|
|
|
system.build.x11Fonts = x11Fonts;
|
|
|
|
|
|
|
|
environment.etc = mkIf config.fonts.enableFontConfig
|
|
|
|
[ { # Configuration file for fontconfig used to locate
|
|
|
|
# (X11) client-rendered fonts.
|
|
|
|
source = pkgs.makeFontsConf {
|
|
|
|
fontDirectories = config.fonts.fonts;
|
|
|
|
};
|
|
|
|
target = "fonts/fonts.conf";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
environment.shellInit =
|
2011-09-14 20:20:50 +02:00
|
|
|
''
|
2009-05-28 14:06:54 +02:00
|
|
|
export FONTCONFIG_FILE=/etc/fonts/fonts.conf
|
|
|
|
'';
|
2009-05-29 15:15:31 +02:00
|
|
|
|
|
|
|
environment.systemPackages =
|
2010-08-10 02:03:36 +02:00
|
|
|
optional config.fonts.enableFontDir config.system.build.x11Fonts ++
|
|
|
|
optional config.fonts.enableFontConfig pkgs.fontconfig;
|
2009-01-02 17:07:39 +01:00
|
|
|
}
|