diff --git a/default.nix b/default.nix index 398a7cc8..73a6b8e4 100644 --- a/default.nix +++ b/default.nix @@ -43,6 +43,7 @@ let ./modules/nix/nix-info.nix ./modules/nix/nixpkgs.nix ./modules/environment + ./modules/fonts ./modules/launchd ./modules/services/activate-system ./modules/services/buildkite-agent.nix diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix new file mode 100644 index 00000000..bacec1a4 --- /dev/null +++ b/modules/fonts/default.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.fonts; +in { + options = { + fonts = { + enableFontDir = mkOption { + default = false; + description = '' + Whether to create a directory with links to all fonts in + /run/current-system/sw/share/fonts. + ''; + }; + fonts = mkOption { + type = types.listOf types.path; + default = []; + example = literalExample "[ pkgs.dejavu_fonts ]"; + description = "List of primary font paths."; + }; + }; + }; + + config = mkIf cfg.enableFontDir { + system.build.fonts = pkgs.buildEnv { + name = "system-fonts"; + paths = cfg.fonts; + pathsToLink = "/share/fonts/truetype"; + }; + system.activationScripts.fonts.text = '' + # Set up fonts. + echo "setting up fonts..." >&2 + /bin/ln -hf ${config.system.build.fonts}/share/fonts/truetype/* /Library/Fonts/ + ''; + environment.pathsToLink = [ "/share/fonts/truetype" ]; + }; + +} diff --git a/modules/system/activation-scripts.nix b/modules/system/activation-scripts.nix index 1a8cfca3..450d65b7 100644 --- a/modules/system/activation-scripts.nix +++ b/modules/system/activation-scripts.nix @@ -64,6 +64,7 @@ in ${cfg.activationScripts.time.text} ${cfg.activationScripts.networking.text} ${cfg.activationScripts.keyboard.text} + ${cfg.activationScripts.fonts.text} ${cfg.activationScripts.postActivation.text}