diff --git a/etc/default.nix b/etc/default.nix index c03b7819a76..731558b67f2 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -173,15 +173,6 @@ let ''; target = "ssmtp/ssmtp.conf"; } - - # Configuration file for fontconfig used to locate - # (X11) client-rendered fonts. - ++ optional config.fonts.enableFontConfig { - source = pkgs.makeFontsConf { - fontDirectories = import ../system/fonts.nix {inherit pkgs config;}; - }; - target = "fonts/fonts.conf"; - } # LDAP configuration. ++ optional config.users.ldap.enable { diff --git a/system/fontdir.nix b/system/fontdir.nix deleted file mode 100644 index 85227930988..00000000000 --- a/system/fontdir.nix +++ /dev/null @@ -1,54 +0,0 @@ -args : with args; with builderDefs; - let localDefs = builderDefs.passthru.function rec { - src = "";/* put a fetchurl here */ - - buildInputs = [mkfontdir mkfontscale ttmkfdir]; - configureFlags = []; - fontDirs = import ./fonts.nix {inherit pkgs config;}; - installPhase = FullDepEntry (" - list=''; - for i in ${toString fontDirs} ; do - if [ -d \$i/ ]; then - list=\"\$list \$i\"; - fi; - done - list=\$(find \$list -name fonts.dir); - fontDirs=''; - for i in \$list ; do - fontDirs=\"\$fontDirs \$(dirname \$i)\"; - done; - mkdir -p \$out/share/X11-fonts/; - for i in \$(find \$fontDirs -type f -o -type l); do - j=\${i##*/} - if ! test -e \$out/share/X11-fonts/\${j}; then - ln -s \$i \$out/share/X11-fonts/\${j}; - fi; - done; - cd \$out/share/X11-fonts/ - rm fonts.dir - rm fonts.scale - rm fonts.alias - mkfontdir - mkfontscale - mv fonts.scale fonts.scale.old - mv fonts.dir fonts.dir.old - ttmkfdir - cat fonts.scale.old >> fonts.scale - cat fonts.dir.old >> fonts.dir - rm fonts.dir.old - rm fonts.scale.old - cat \$( find ${fontalias}/ -name fonts.alias) >fonts.alias - ") ["minInit" "addInputs"]; - }; - in with localDefs; -stdenv.mkDerivation rec { - name = "X11-fonts"; - builder = writeScript (name + "-builder") - (textClosure localDefs - [installPhase doForceShare doPropagate]); - meta = { - description = " - Directory to contain all X11 fonts requested. -"; - }; -} diff --git a/system/fonts.nix b/system/fonts.nix index f0be6dd1de0..6afe44fe99a 100644 --- a/system/fonts.nix +++ b/system/fonts.nix @@ -1,27 +1,178 @@ -{pkgs, config}: +{pkgs, config, ...}: -[ - # - the user's .fonts directory - "~/.fonts" - # - the user's current profile - "~/.nix-profile/lib/X11/fonts" - "~/.nix-profile/share/fonts" - # - the default profile - "/nix/var/nix/profiles/default/lib/X11/fonts" - "/nix/var/nix/profiles/default/share/fonts" - # - a few statically built locations - pkgs.xorg.fontbhttf - pkgs.xorg.fontbhlucidatypewriter100dpi - pkgs.xorg.fontbhlucidatypewriter75dpi - pkgs.ttf_bitstream_vera - pkgs.freefont_ttf - pkgs.xorg.fontbh100dpi - pkgs.xorg.fontmiscmisc - pkgs.xorg.fontcursormisc -] +###### interface +let + inherit (pkgs.lib) mkOption; -++ pkgs.lib.optional config.fonts.enableCoreFonts pkgs.corefonts + options = { -++ pkgs.lib.optional config.fonts.enableGhostscriptFonts "${pkgs.ghostscript}/share/ghostscript/fonts" + fonts = { -++ config.fonts.extraFonts + 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. + "; + }; + + # should be move elsewhere. + 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 = " + Whether to create a directory with links to all fonts in share - + so user can configure vncserver script one time (I mean per-user + 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 + "/nix/var/nix/profiles/default/lib/X11/fonts" + "/nix/var/nix/profiles/default/share/fonts" + ]; + 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 + pkgs.xorg.fontbh100dpi + pkgs.xorg.fontmiscmisc + pkgs.xorg.fontcursormisc + ] + ++ pkgs.lib.optional config.fonts.enableCoreFonts pkgs.corefonts + ++ pkgs.lib.optional config.fonts.enableGhostscriptFonts "${pkgs.ghostscript}/share/ghostscript/fonts" + ++ config.fonts.extraFonts; + }; + + extraFonts = mkOption { + default = []; + description = " + List of additional fonts. + "; + }; + + enableCoreFonts = mkOption { + default = true; + description = " + Whether to include MS Core Fonts (redistributable, but only verbatim). + "; + }; + + }; + + }; +in + +###### implementation +let + inherit (pkgs) builderDefs ttmkfdir; + inherit (pkgs.xorg) mkfontdir mkfontscale fontalias; + + fontDirs = config.fonts.fonts; + + + localDefs = with builderDefs; builderDefs.passthru.function rec { + src = "";/* put a fetchurl here */ + + buildInputs = [mkfontdir mkfontscale ttmkfdir]; + configureFlags = []; + inherit fontDirs; + installPhase = FullDepEntry (" + list=''; + for i in ${toString fontDirs} ; do + if [ -d \$i/ ]; then + list=\"\$list \$i\"; + fi; + done + list=\$(find \$list -name fonts.dir); + fontDirs=''; + for i in \$list ; do + fontDirs=\"\$fontDirs \$(dirname \$i)\"; + done; + mkdir -p \$out/share/X11-fonts/; + for i in \$(find \$fontDirs -type f -o -type l); do + j=\${i##*/} + if ! test -e \$out/share/X11-fonts/\${j}; then + ln -s \$i \$out/share/X11-fonts/\${j}; + fi; + done; + cd \$out/share/X11-fonts/ + rm fonts.dir + rm fonts.scale + rm fonts.alias + mkfontdir + mkfontscale + mv fonts.scale fonts.scale.old + mv fonts.dir fonts.dir.old + ttmkfdir + cat fonts.scale.old >> fonts.scale + cat fonts.dir.old >> fonts.dir + rm fonts.dir.old + rm fonts.scale.old + cat \$( find ${fontalias}/ -name fonts.alias) >fonts.alias + ") ["minInit" "addInputs"]; + }; + + x11Fonts = with localDefs; stdenv.mkDerivation rec { + name = "X11-fonts"; + builder = writeScript (name + "-builder") + (textClosure localDefs + [installPhase doForceShare doPropagate]); + meta = { + description = " + Directory to contain all X11 fonts requested. + "; + }; + }; + + inherit (pkgs.lib) mkIf; +in + +{ + require = [ + options + ]; + + system = { + build = { + inherit x11Fonts; + }; + }; + + environment = { + # Configuration file for fontconfig used to locate + # (X11) client-rendered fonts. + etc = mkIf config.fonts.enableFontConfig [{ + source = pkgs.makeFontsConf { + fontDirectories = config.fonts.fonts; + }; + target = "fonts/fonts.conf"; + }]; + }; +} diff --git a/system/options.nix b/system/options.nix index f9be98fdcc1..ad97565bb97 100644 --- a/system/options.nix +++ b/system/options.nix @@ -2271,56 +2271,6 @@ in }; - 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. - "; - }; - - 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 = " - Whether to create a directory with links to all fonts in share - - so user can configure vncserver script one time (I mean per-user - vncserver, so global service is not a good solution). - "; - }; - - extraFonts = mkOption { - default = []; - merge = backwardPkgsFunListMerge; - description = " - Function, returning list of additional fonts. - "; - }; - - enableCoreFonts = mkOption { - default = true; - description = " - Whether to include MS Core Fonts (redistributable, but only verbatim). - "; - }; - - }; - - i18n = { defaultLocale = mkOption { @@ -2475,6 +2425,9 @@ in (import ../upstart-jobs/cron.nix) (import ../upstart-jobs/cron/locate.nix) + # fonts + (import ../system/fonts.nix) + # sound (import ../upstart-jobs/alsa.nix) ]; diff --git a/system/system.nix b/system/system.nix index 0ef870b8806..0eb86cc857d 100644 --- a/system/system.nix +++ b/system/system.nix @@ -73,11 +73,7 @@ rec { # Font aggregation - fontDir = import ./fontdir.nix { - inherit config pkgs; - inherit (pkgs) builderDefs ttmkfdir; - inherit (pkgs.xorg) mkfontdir mkfontscale fontalias; - }; + fontDir = config.system.build.x11Fonts; # The wrapper setuid programs (since we can't have setuid programs diff --git a/upstart-jobs/xserver.nix b/upstart-jobs/xserver.nix index dd8d6bed479..231bcd943ad 100644 --- a/upstart-jobs/xserver.nix +++ b/upstart-jobs/xserver.nix @@ -4,7 +4,7 @@ let kernelPackages = config.boot.kernelPackages; # List of font directories. - fontDirectories = import ../system/fonts.nix {inherit pkgs config;}; + fontDirectories = config.fonts.fonts; inherit (pkgs.lib) mkOption; @@ -759,6 +759,9 @@ mkIf cfg.enable { # environment.etc (import ../etc/default.nix) + # fonts.fonts + (import ../system/fonts.nix) + # boot.extraModulePackages # security.extraSetuidPrograms # environment.extraPackages