Get filename from metadata, add gg sans
This commit is contained in:
parent
ecdb1288eb
commit
4013f8df73
40
flake.nix
40
flake.nix
|
@ -13,13 +13,11 @@
|
|||
with builtins;
|
||||
with nixpkgs.lib;
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
buildFont = {
|
||||
name,
|
||||
files,
|
||||
license,
|
||||
author,
|
||||
}: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
|
||||
pathEndsWith = suffix: path: let
|
||||
str = toString path;
|
||||
sufLen = stringLength suffix;
|
||||
|
@ -27,20 +25,30 @@
|
|||
in
|
||||
sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str;
|
||||
|
||||
installType = extension: pathName: let
|
||||
buildFont = {
|
||||
name,
|
||||
files,
|
||||
license,
|
||||
author,
|
||||
}: let
|
||||
copyType = extension: pathName: let
|
||||
filteredFiles = filter (pathEndsWith ("." + extension)) files;
|
||||
filename = file: lists.last (strings.splitString "/" (toString file));
|
||||
in
|
||||
(optionalString (filteredFiles != []) "mkdir -p $out/share/fonts/${pathName}\n")
|
||||
+ concatStringsSep "\n" (map (file: "cp -v ${file} $out/share/fonts/${pathName}/${filename file}") filteredFiles);
|
||||
+ concatStringsSep "\n" (map (file: ''
|
||||
filename=$(${pkgs.fontconfig}/bin/fc-query -f %{postscriptname} ${file}).${extension}
|
||||
cp -v ${file} $out/share/fonts/${pathName}/$filename
|
||||
'')
|
||||
filteredFiles);
|
||||
in
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
inherit name;
|
||||
|
||||
dontUnpack = true;
|
||||
installPhase = ''
|
||||
${installType "ttf" "truetype"}
|
||||
${installType "otf" "opentype"}
|
||||
${copyType "ttf" "truetype"}
|
||||
${copyType "otf" "opentype"}
|
||||
${copyType "woff2" "woff2"}
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
@ -57,10 +65,16 @@
|
|||
license = licenses.cc-by-40;
|
||||
author = "Matthew Anderson";
|
||||
}
|
||||
{
|
||||
name = "gg sans";
|
||||
files = [./ggsans-Normal.woff2 ./ggsans-Medium.woff2 ./ggsans-SemiBold.woff2];
|
||||
license = licenses.unfree;
|
||||
author = "Colophon Foundry";
|
||||
}
|
||||
];
|
||||
in {
|
||||
packages = listToAttrs (map (font: {
|
||||
name = toLower font.name;
|
||||
name = replaceStrings [" "] ["-"] (toLower font.name);
|
||||
value = buildFont font;
|
||||
})
|
||||
fonts);
|
||||
|
|
BIN
ggsans-Medium.woff2
Normal file
BIN
ggsans-Medium.woff2
Normal file
Binary file not shown.
BIN
ggsans-Normal.woff2
Normal file
BIN
ggsans-Normal.woff2
Normal file
Binary file not shown.
BIN
ggsans-SemiBold.woff2
Normal file
BIN
ggsans-SemiBold.woff2
Normal file
Binary file not shown.
Loading…
Reference in a new issue