Compare commits
2 commits
90dfd51d7c
...
587fad82e8
Author | SHA1 | Date | |
---|---|---|---|
Artemis Tosini | 587fad82e8 | ||
Artemis Tosini | d42faf4840 |
|
@ -1,4 +1,11 @@
|
|||
{ lib, fetchurl, stdenvNoCC, unzip, ipsw, _7zz }:
|
||||
{
|
||||
lib,
|
||||
fetchurl,
|
||||
stdenvNoCC,
|
||||
unzip,
|
||||
ipsw,
|
||||
_7zz,
|
||||
}:
|
||||
let
|
||||
root = lib.importJSON ./assets.json;
|
||||
|
||||
|
@ -32,12 +39,16 @@ let
|
|||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
extra = lib.mapAttrs' mkExtraFont root.extra;
|
||||
allExtra = (mkExtraFont "All Extra" root.all_extra).value;
|
||||
|
||||
base = let data = root.base;
|
||||
in stdenvNoCC.mkDerivation {
|
||||
base =
|
||||
let
|
||||
data = root.base;
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "macos-fonts-base";
|
||||
version = with data; "${version}-${build}";
|
||||
|
||||
|
|
41
flake.lock
41
flake.lock
|
@ -5,9 +5,7 @@
|
|||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"utils": [
|
||||
"flake-utils"
|
||||
]
|
||||
"utils": "utils"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1720584070,
|
||||
|
@ -23,24 +21,6 @@
|
|||
"url": "https://git.mildlyfunctional.gay/artemist/packages.git"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1721066811,
|
||||
|
@ -59,7 +39,6 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"artemist": "artemist",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
|
@ -77,6 +56,24 @@
|
|||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
115
flake.nix
115
flake.nix
|
@ -1,20 +1,32 @@
|
|||
{
|
||||
description = "Various fonts I've found online";
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "github:nixos/nixpkgs";
|
||||
artemist = {
|
||||
url = "git+https://git.mildlyfunctional.gay/artemist/packages.git";
|
||||
inputs.utils.follows = "flake-utils";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, artemist }:
|
||||
with nixpkgs.lib;
|
||||
outputs =
|
||||
{
|
||||
overlays.default = (final: prev:
|
||||
self,
|
||||
nixpkgs,
|
||||
artemist,
|
||||
}:
|
||||
with nixpkgs.lib;
|
||||
let
|
||||
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
||||
makePkgs =
|
||||
system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
self.overlays.default
|
||||
artemist.overlays.default
|
||||
];
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
localFonts = [
|
||||
{
|
||||
# Popular font, used on NYC Subway
|
||||
|
@ -125,77 +137,44 @@
|
|||
author = "Kontrapunkt";
|
||||
}
|
||||
];
|
||||
buildLocalFont = { name, files ? [ ], dir ? null, license, author }:
|
||||
in
|
||||
{
|
||||
overlays.default = (
|
||||
final: prev:
|
||||
let
|
||||
types = {
|
||||
ttf = "truetype";
|
||||
otf = "opentype";
|
||||
};
|
||||
|
||||
pathEndsWith = suffix: path:
|
||||
let
|
||||
str = toString path;
|
||||
sufLen = stringLength suffix;
|
||||
sLen = stringLength str;
|
||||
in sufLen <= sLen && suffix
|
||||
== substring (sLen - sufLen) sufLen str;
|
||||
|
||||
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}
|
||||
'') + concatStringsSep "\n" (map (file:
|
||||
"cp -v ${file} $out/share/fonts/${pathName}/${filename file}")
|
||||
filteredFiles);
|
||||
|
||||
copyTypeDir = extension: pathName: ''
|
||||
if [ -n "$(shopt -s nullglob; echo ${dir}/*.${extension})" ]; then
|
||||
mkdir -p $out/share/fonts/${pathName}
|
||||
cp -v -t $out/share/fonts/${pathName} ${dir}/*.${extension}
|
||||
fi
|
||||
'';
|
||||
|
||||
in final.stdenvNoCC.mkDerivation {
|
||||
inherit name;
|
||||
dontUnpack = true;
|
||||
installPhase = mapAttrsToList copyType types
|
||||
++ optional (dir != null) (mapAttrsToList copyTypeDir types);
|
||||
|
||||
passthru.font = true;
|
||||
meta = {
|
||||
inherit license;
|
||||
platforms = platforms.all;
|
||||
maintainers = [ maintainers.artemist ];
|
||||
description = "${name} font by ${author}";
|
||||
};
|
||||
};
|
||||
in {
|
||||
extraFonts = listToAttrs (map (font: {
|
||||
buildLocalFont = final.callPackage ./nix/buildLocalFont.nix { };
|
||||
in
|
||||
{
|
||||
extraFonts = listToAttrs (
|
||||
map (font: {
|
||||
name = replaceStrings [ " " ] [ "-" ] (toLower font.name);
|
||||
value = buildLocalFont font;
|
||||
}) localFonts);
|
||||
}) localFonts
|
||||
);
|
||||
appleFonts = final.callPackage ./apple {
|
||||
ipsw = if final ? ipsw then final.ipsw else artemist.packages.${final.stdenv.system}.ipsw;
|
||||
};
|
||||
});
|
||||
} // flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlays.default artemist.overlays.default ];
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
in {
|
||||
packages = builtins.listToAttrs (map (name: {
|
||||
}
|
||||
);
|
||||
|
||||
packages = forAllSystems (
|
||||
system:
|
||||
builtins.listToAttrs (
|
||||
map
|
||||
(name: {
|
||||
inherit name;
|
||||
value = pkgs.${name} // {
|
||||
value = (makePkgs system).${name} // {
|
||||
type = "derivation";
|
||||
name = "dummy-attrset";
|
||||
};
|
||||
}) [ "extraFonts" "appleFonts" ]);
|
||||
formatter = pkgs.nixfmt;
|
||||
});
|
||||
})
|
||||
[
|
||||
"extraFonts"
|
||||
"appleFonts"
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
formatter = forAllSystems (system: (makePkgs system).nixfmt-rfc-style);
|
||||
};
|
||||
}
|
||||
|
|
58
nix/buildLocalFont.nix
Normal file
58
nix/buildLocalFont.nix
Normal file
|
@ -0,0 +1,58 @@
|
|||
{ lib, stdenvNoCC }:
|
||||
{
|
||||
name,
|
||||
files ? [ ],
|
||||
dir ? null,
|
||||
license,
|
||||
author,
|
||||
}:
|
||||
let
|
||||
types = {
|
||||
ttf = "truetype";
|
||||
otf = "opentype";
|
||||
};
|
||||
|
||||
pathEndsWith =
|
||||
suffix: path:
|
||||
let
|
||||
str = toString path;
|
||||
sufLen = lib.stringLength suffix;
|
||||
sLen = lib.stringLength str;
|
||||
in
|
||||
sufLen <= sLen && suffix == lib.substring (sLen - sufLen) sufLen str;
|
||||
|
||||
copyType =
|
||||
extension: pathName:
|
||||
let
|
||||
filteredFiles = lib.filter (pathEndsWith ("." + extension)) files;
|
||||
filename = file: lib.lists.last (lib.strings.splitString "/" (toString file));
|
||||
in
|
||||
(lib.optionalString (filteredFiles != [ ]) ''
|
||||
mkdir -p $out/share/fonts/${pathName}
|
||||
'')
|
||||
+ lib.concatStringsSep "\n" (
|
||||
map (file: "cp -v ${file} $out/share/fonts/${pathName}/${filename file}") filteredFiles
|
||||
);
|
||||
|
||||
copyTypeDir = extension: pathName: ''
|
||||
if [ -n "$(shopt -s nullglob; echo ${dir}/*.${extension})" ]; then
|
||||
mkdir -p $out/share/fonts/${pathName}
|
||||
cp -v -t $out/share/fonts/${pathName} ${dir}/*.${extension}
|
||||
fi
|
||||
'';
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
inherit name;
|
||||
dontUnpack = true;
|
||||
installPhase =
|
||||
lib.mapAttrsToList copyType types
|
||||
++ lib.optional (dir != null) (lib.mapAttrsToList copyTypeDir types);
|
||||
|
||||
passthru.font = true;
|
||||
meta = with lib; {
|
||||
inherit license;
|
||||
platforms = platforms.all;
|
||||
maintainers = [ maintainers.artemist ];
|
||||
description = "${name} font by ${author}";
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue