-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathflake.nix
More file actions
97 lines (87 loc) · 2.89 KB
/
flake.nix
File metadata and controls
97 lines (87 loc) · 2.89 KB
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
{
description = "A bitmap programming font optimized for coziness";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
in
{
devShells = {
default = pkgs.mkShellNoCC {
packages = with pkgs; [
# FontForge GUI
fontforge-gtk
# Python tools
python312Packages.black
python312Packages.mypy
python312Packages.isort
python312Packages.ruff
];
};
};
packages = rec {
# Derivation to build and install cozette
cozette = pkgs.stdenvNoCC.mkDerivation {
pname = "cozette";
version =
let
sfdLines = lib.strings.splitString "\n" (builtins.readFile ./Cozette/Cozette.sfd);
sfdVersionLine = lib.lists.findFirst (l: lib.strings.hasPrefix "Version: " l) null sfdLines;
sfdVersion =
if sfdVersionLine != null then lib.strings.removePrefix "Version: " sfdVersionLine else "0.00";
majorRest = lib.strings.splitString "." sfdVersion;
major = builtins.elemAt majorRest 0;
minorPatch = builtins.elemAt majorRest 1;
minor = builtins.substring 0 2 minorPatch;
patch = builtins.substring 2 1 minorPatch;
in
"${major}.${minor}.${patch}";
src = ./.;
buildInputs = with pkgs; [
(pkgs.python312.withPackages (
ppkgs: with ppkgs; [
numpy
pillow
fonttools
crayons
gitpython
setuptools
pip
]
))
fontforge
bitsnpicas
];
postPatch = ''
substituteInPlace build.py --replace-fail \
'bitsnpicas.sh' '${lib.getExe pkgs.bitsnpicas}'
'';
buildPhase = ''
python3 build.py fonts
'';
installPhase = ''
runHook preInstall
cd build
install -Dm644 *.ttf -t $out/share/fonts/truetype
install -Dm644 *.otf -t $out/share/fonts/opentype
install -Dm644 *.bdf -t $out/share/fonts/misc
install -Dm644 *.otb -t $out/share/fonts/misc
install -Dm644 *.woff -t $out/share/fonts/woff
install -Dm644 *.woff2 -t $out/share/fonts/woff2
runHook postInstall
'';
};
default = cozette;
};
}
);
}