-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathflake.nix
128 lines (110 loc) · 4.02 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
sf-pro = {
url = "https://devimages-cdn.apple.com/design/resources/download/SF-Pro.dmg";
flake = false;
};
sf-compact = {
url = "https://devimages-cdn.apple.com/design/resources/download/SF-Compact.dmg";
flake = false;
};
sf-mono = {
url = "https://devimages-cdn.apple.com/design/resources/download/SF-Mono.dmg";
flake = false;
};
sf-arabic = {
url = "https://devimages-cdn.apple.com/design/resources/download/SF-Arabic.dmg";
flake = false;
};
ny = {
url = "https://devimages-cdn.apple.com/design/resources/download/NY.dmg";
flake = false;
};
};
outputs =
inputs:
let
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
forEachSystem = inputs.nixpkgs.lib.genAttrs systems;
in
{
packages = forEachSystem (
system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
unpackPhase = pkgName: ''
runHook preUnpack
undmg $src
7z x '${pkgName}'
7z x 'Payload~'
runHook postUnpack
'';
commonInstall = ''
mkdir -p "$out/share/fonts"
mkdir -p "$out/share/fonts/opentype"
mkdir -p "$out/share/fonts/truetype"
'';
commonBuildInputs = builtins.attrValues { inherit (pkgs) undmg p7zip; };
makeAppleFont = (
name: pkgName: src:
pkgs.stdenvNoCC.mkDerivation {
inherit name src;
unpackPhase = unpackPhase pkgName;
buildInputs = commonBuildInputs;
setSourceRoot = "sourceRoot=`pwd`";
installPhase =
''runHook preInstall''
+ commonInstall
+ ''
find -name \*.otf -exec mv {} "$out/share/fonts/opentype/" \;
find -name \*.ttf -exec mv {} "$out/share/fonts/truetype/" \;
''
+ ''runHook preInstall'';
}
);
makeNerdAppleFont = (
name: pkgName: src:
pkgs.stdenvNoCC.mkDerivation {
inherit name src;
unpackPhase = unpackPhase pkgName;
buildInputs =
commonBuildInputs
++ builtins.attrValues { inherit (pkgs) parallel nerd-font-patcher; };
setSourceRoot = "sourceRoot=`pwd`";
buildPhase = ''
runHook preBuild
find -name \*.ttf -o -name \*.otf -print0 | parallel -j $NIX_BUILD_CORES -0 nerd-font-patcher -c {}
runHook postBuild
'';
installPhase =
''runHook preInstall''
+ commonInstall
+ ''
find -name \*.otf -maxdepth 1 -exec mv {} "$out/share/fonts/opentype/" \;
find -name \*.ttf -maxdepth 1 -exec mv {} "$out/share/fonts/truetype/" \;
''
+ ''runHook preInstall'';
}
);
in
{
sf-pro = makeAppleFont "sf-pro" "SF Pro Fonts.pkg" inputs.sf-pro;
sf-pro-nerd = makeNerdAppleFont "sf-pro-nerd" "SF Pro Fonts.pkg" inputs.sf-pro;
sf-compact = makeAppleFont "sf-compact" "SF Compact Fonts.pkg" inputs.sf-compact;
sf-compact-nerd = makeNerdAppleFont "sf-compact-nerd" "SF Compact Fonts.pkg" inputs.sf-compact;
sf-mono = makeAppleFont "sf-mono" "SF Mono Fonts.pkg" inputs.sf-mono;
sf-mono-nerd = makeNerdAppleFont "sf-mono-nerd" "SF Mono Fonts.pkg" inputs.sf-mono;
sf-arabic = makeAppleFont "sf-arabic" "SF Arabic Fonts.pkg" inputs.sf-arabic;
sf-arabic-nerd = makeNerdAppleFont "sf-arabic-nerd" "SF Arabic Fonts.pkg" inputs.sf-arabic;
ny = makeAppleFont "ny" "NY Fonts.pkg" inputs.ny;
ny-nerd = makeNerdAppleFont "ny-nerd" "NY Fonts.pkg" inputs.ny;
}
);
};
}