feat: install fonts

This commit is contained in:
Gustavo "Guz" L. de Mello
2024-02-12 21:40:08 -03:00
parent 02d4d7c0ce
commit 6241837bb8
3 changed files with 68 additions and 2 deletions

View File

@@ -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;
};
}

View File

@@ -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'.

View File

@@ -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;
};
};
};
}