-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
flake.nix
202 lines (179 loc) · 5.62 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
deno2nix = {
url = "github:Xe/deno2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
# Explicitly pulling from that version of nixpkgs to avoid font duplication.
iosevka.url = "github:Xe/iosevka";
typst.url = "github:typst/typst";
typst.inputs.nixpkgs.follows = "nixpkgs";
alpineLinux = {
flake = false;
url =
"file+https://cdn.xeiaso.net/file/christine-static/hack/alpine-amd64-3.19.0-1.tar";
};
};
outputs = { self, nixpkgs, flake-utils, deno2nix, iosevka, typst, gomod2nix
, alpineLinux, ... }:
flake-utils.lib.eachSystem [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
] (system:
let
graft = pkgs: pkg:
pkg.override { buildGoModule = pkgs.buildGo122Module; };
pkgs = import nixpkgs {
inherit system;
overlays = [
deno2nix.overlays.default
typst.overlays.default
(final: prev: {
go = prev.go_1_22;
go-tools = graft prev prev.go-tools;
gotools = graft prev prev.gotools;
gopls = graft prev prev.gopls;
})
gomod2nix.overlays.default
];
};
src = ./.;
lib = pkgs.lib;
fontsConf = pkgs.symlinkJoin {
name = "typst-fonts";
paths = [ "${self.packages.${system}.iosevka}/static/css/iosevka" ];
};
typstWithIosevka = pkgs.writeShellApplication {
name = "typst";
text = ''
${pkgs.typst-dev}/bin/typst \
compile \
--font-path ${fontsConf} \
"$@"
'';
runtimeInputs = [ ];
};
# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
in rec {
packages = rec {
bin = pkgs.buildGoApplication {
pname = "xesite_v4";
inherit version;
src = ./.;
modules = ./gomod2nix.toml;
subPackages = [ "cmd/xesite" ];
};
patreon-bin = pkgs.buildGoApplication {
pname = "patreon-saasproxy";
inherit version;
src = ./.;
modules = ./gomod2nix.toml;
subPackages = [ "cmd/patreon-saasproxy" ];
};
iosevka = pkgs.stdenvNoCC.mkDerivation {
name = "xesite-iosevka";
buildInputs = with pkgs; [
python311Packages.brotli
python311Packages.fonttools
];
dontUnpack = true;
buildPhase = ''
mkdir -p out
${pkgs.unzip}/bin/unzip ${
self.inputs.iosevka.packages.${system}.default
}/ttf.zip
for ttf in ttf/*.ttf; do
cp $ttf out
name=`basename -s .ttf $ttf`
pyftsubset \
$ttf \
--output-file=out/"$name".woff2 \
--flavor=woff2 \
--layout-features=* \
--no-hinting \
--desubroutinize \
--unicodes="U+0000-0170,U+00D7,U+00F7,U+2000-206F,U+2074,U+20AC,U+2122,U+2190-21BB,U+2212,U+2215,U+F8FF,U+FEFF,U+FFFD,U+00E8"
done
'';
installPhase = ''
mkdir -p $out/static/css/iosevka
cp out/* $out/static/css/iosevka
'';
};
docker = pkgs.dockerTools.buildLayeredImage {
name = "ghcr.io/xe/site/bin";
tag = "latest";
fromImage = alpineLinux;
contents = with pkgs; [ cacert typst-dev dhall-json deno git ];
config = {
Cmd = [ "${bin}/bin/xesite" "--data-dir=/data" ];
Env = [
"HOME=/data"
"DHALL_PRELUDE=${pkgs.dhallPackages.Prelude}"
"TYPST_FONT_PATHS=${fontsConf}"
];
Volumes."/data" = { };
};
};
patreon-docker = pkgs.dockerTools.buildLayeredImage {
name = "ghcr.io/xe/site/patreon";
tag = "latest";
contents = with pkgs; [ cacert ];
config = {
Cmd = [ "${patreon-bin}/bin/patreon-saasproxy" ];
Env = [ "HOME=/data" ];
Volumes."/data" = { };
};
};
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
# Go
go
go-tools
gotools
gopls
gomod2nix.packages.${system}.default
# dhall
dhall
dhall-json
typst-dev
pagefind
# frontend
deno
nodePackages.uglify-js
esbuild
zig
nodejs
protobuf
protoc-gen-go
protoc-gen-twirp
jq
jo
earthly
# tools
ispell
pandoc
python311Packages.fonttools
];
DHALL_PRELUDE = "${pkgs.dhallPackages.Prelude}";
TYPST_FONT_PATHS = "${fontsConf}";
FLY_REGION = "dev";
};
});
}