diff --git a/hosts/desktop/shared-configuration.nix b/hosts/desktop/shared-configuration.nix index 7925e83..42ba344 100644 --- a/hosts/desktop/shared-configuration.nix +++ b/hosts/desktop/shared-configuration.nix @@ -4,12 +4,40 @@ imports = [ ../../modules/nixos/config/host.nix ../../modules/nixos/systems/set-user.nix + ../../modules/nixos/systems/fonts.nix # Include the results of the hardware scan. ./hardware-configuration.nix ]; options.shared.configuration = { }; config = { + my-fonts.enable = true; + my-fonts.user = "guz"; + my-fonts.fonts = with pkgs; [ + fira-code + (nerdfonts.override { fonts = [ "FiraCode" ]; }) + (google-fonts.override { fonts = [ "Gloock" "Cinzel" ]; }) + (stdenv.mkDerivation rec { + pname = "calsans"; + version = "1.0.0"; + src = pkgs.fetchzip { + url = "https://github.com/calcom/font/releases/download/v${version}/CalSans_Semibold_v${version}.zip"; + stripRoot = false; + hash = "sha256-JqU64JUgWimJgrKX3XYcml8xsvy//K7O5clNKJRGaTM="; + }; + installPhase = '' + runHook preInstall + install -m444 -Dt $out/share/fonts/truetype fonts/webfonts/*.ttf + runHook postInstall + ''; + meta = with lib; { + homepage = "https://github.com/calcom/font"; + license = licenses.ofl; + platforms = platforms.all; + }; + }) + ]; + sops.defaultSopsFile = ../../secrets/desktop-secrets.yaml; sops.defaultSopsFormat = "yaml"; @@ -101,3 +129,4 @@ # networking.firewall.enable = false; }; } + diff --git a/hosts/desktop/shared-home.nix b/hosts/desktop/shared-home.nix index 5670b47..1e6214c 100644 --- a/hosts/desktop/shared-home.nix +++ b/hosts/desktop/shared-home.nix @@ -83,8 +83,6 @@ (nerdfonts.override { fonts = [ "FiraCode" ]; }) ]; - fonts.fontconfig.enable = true; - # Home Manager is pretty good at managing dotfiles. The primary way to manage # plain files is through 'home.file'. diff --git a/modules/nixos/systems/fonts.nix b/modules/nixos/systems/fonts.nix new file mode 100644 index 0000000..6f9b62c --- /dev/null +++ b/modules/nixos/systems/fonts.nix @@ -0,0 +1,39 @@ +{ config, lib, ... }: + +let + cfg = config.my-fonts; +in +{ + imports = [ ]; + options.my-fonts = with lib; with lib.types; { + enable = mkEnableOption ""; + fonts = mkOption { + type = listOf package; + default = [ ]; + }; + user = mkOption { + type = str; + }; + }; + config = lib.mkIf cfg.enable { + fonts = { + fontconfig.enable = true; + fontDir.enable = true; + packages = cfg.fonts; + }; + systemd.services."my-fonts-setup" = { + script = '' + if [ -d "/home/${cfg.user}/.local/share/fonts" ]; then + echo ""; + else + ln -sf /run/current-system/sw/share/X11/fonts /home/${cfg.user}/.local/share/fonts; + fi + ''; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + User = cfg.user; + }; + }; + }; +}