Get filename from metadata, add gg sans
This commit is contained in:
parent
ecdb1288eb
commit
4013f8df73
42
flake.nix
42
flake.nix
|
@ -13,34 +13,42 @@
|
||||||
with builtins;
|
with builtins;
|
||||||
with nixpkgs.lib;
|
with nixpkgs.lib;
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
pkgs = import nixpkgs {inherit system;};
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
config.allowUnfree = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
pathEndsWith = suffix: path: let
|
||||||
|
str = toString path;
|
||||||
|
sufLen = stringLength suffix;
|
||||||
|
sLen = stringLength str;
|
||||||
|
in
|
||||||
|
sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str;
|
||||||
|
|
||||||
buildFont = {
|
buildFont = {
|
||||||
name,
|
name,
|
||||||
files,
|
files,
|
||||||
license,
|
license,
|
||||||
author,
|
author,
|
||||||
}: let
|
}: let
|
||||||
pathEndsWith = suffix: path: let
|
copyType = extension: pathName: let
|
||||||
str = toString path;
|
|
||||||
sufLen = stringLength suffix;
|
|
||||||
sLen = stringLength str;
|
|
||||||
in
|
|
||||||
sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str;
|
|
||||||
|
|
||||||
installType = extension: pathName: let
|
|
||||||
filteredFiles = filter (pathEndsWith ("." + extension)) files;
|
filteredFiles = filter (pathEndsWith ("." + extension)) files;
|
||||||
filename = file: lists.last (strings.splitString "/" (toString file));
|
|
||||||
in
|
in
|
||||||
(optionalString (filteredFiles != []) "mkdir -p $out/share/fonts/${pathName}\n")
|
(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
|
in
|
||||||
pkgs.stdenvNoCC.mkDerivation {
|
pkgs.stdenvNoCC.mkDerivation {
|
||||||
inherit name;
|
inherit name;
|
||||||
|
|
||||||
dontUnpack = true;
|
dontUnpack = true;
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
${installType "ttf" "truetype"}
|
${copyType "ttf" "truetype"}
|
||||||
${installType "otf" "opentype"}
|
${copyType "otf" "opentype"}
|
||||||
|
${copyType "woff2" "woff2"}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
@ -57,10 +65,16 @@
|
||||||
license = licenses.cc-by-40;
|
license = licenses.cc-by-40;
|
||||||
author = "Matthew Anderson";
|
author = "Matthew Anderson";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "gg sans";
|
||||||
|
files = [./ggsans-Normal.woff2 ./ggsans-Medium.woff2 ./ggsans-SemiBold.woff2];
|
||||||
|
license = licenses.unfree;
|
||||||
|
author = "Colophon Foundry";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
in {
|
in {
|
||||||
packages = listToAttrs (map (font: {
|
packages = listToAttrs (map (font: {
|
||||||
name = toLower font.name;
|
name = replaceStrings [" "] ["-"] (toLower font.name);
|
||||||
value = buildFont font;
|
value = buildFont font;
|
||||||
})
|
})
|
||||||
fonts);
|
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