Provide Fira Code with pre‐set features

This commit is contained in:
Mikael 2024-08-26 13:18:45 +02:00
parent e85c40310a
commit 44ad76b6b9
Signed by: mikael
SSH key fingerprint: SHA256:21QyD2Meiot7jOUVitIR5YkGB/XuXdCvLW1hE6dsri0
2 changed files with 52 additions and 2 deletions

View file

@ -1,4 +1,4 @@
{ ... }: { config, lib, pkgs, ... }@args: { self, ... }: { config, lib, pkgs, ... }@args:
let let
osConfig = args.osConfig or { }; osConfig = args.osConfig or { };
in lib.mkIf (osConfig.hardware.graphics.enable or false) { in lib.mkIf (osConfig.hardware.graphics.enable or false) {
@ -30,7 +30,9 @@ in lib.mkIf (osConfig.hardware.graphics.enable or false) {
home.packages = with pkgs; [ home.packages = with pkgs; [
lato lato
fira-code (self.packages.${pkgs.system}.fira-code.override {
fontFeatures = [ "cv01" "cv06" "onum" "ss01" "ss03" "ss06" "ss07" "ss08" "zero" ];
})
mplus-outline-fonts.githubRelease mplus-outline-fonts.githubRelease
(nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; }) (nerdfonts.override { fonts = [ "NerdFontsSymbolsOnly" ]; })
noto-fonts noto-fonts

48
package/fira-code.nix Normal file
View file

@ -0,0 +1,48 @@
{ ... }: {
stdenv,
lib,
fetchFromGitHub,
python3,
ttfautohint,
fontFeatures ? [ ]
}:
stdenv.mkDerivation (finalAttrs: {
__structuredAttrs = true;
pname = "fira-code";
version = "unstable-2024-02-29";
src = fetchFromGitHub {
owner = "tonsky";
repo = "FiraCode";
rev = "34cced2a1235e2035fb1f258f228b0ed584b8911";
hash = "sha256-1cLjAqdm2oG39ML9CuVeoQKb9SR1QX9k7qt2cfl7098=";
};
nativeBuildInputs = [
(python3.withPackages (ps: with ps; [ fontmake ]))
ttfautohint
];
inherit fontFeatures;
postPatch = ''
patchShebangs script
'';
buildPhase = ''
runHook preBuild
./script/bake_in_features.sh "''${fontFeatures[@]}"
./script/build_ttf.sh
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -D -m 0644 -t "$out/share/fonts" distr/ttf/Fira\ Code/*.ttf
runHook postInstall
'';
})