-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
121 lines (101 loc) · 2.72 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
{
inputs = {
crane = {
url = "github:ipetkov/crane";
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
};
nixpkgs = {
url = "github:nixos/nixpkgs/nixos-unstable";
};
# TODO https://github.com/NixOS/nixpkgs/issues/261820
nixpkgs-iosevka = {
url = "github:nixos/nixpkgs/nixos-22.11";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
};
utils = {
url = "github:numtide/flake-utils";
};
};
outputs =
{
self,
crane,
nixpkgs,
nixpkgs-iosevka,
rust-overlay,
utils,
}:
utils.lib.eachDefaultSystem (
system:
let
pkgs' = import nixpkgs {
inherit system;
overlays = [
(import rust-overlay)
];
};
pkgs-iosevka = import nixpkgs-iosevka {
inherit system;
};
pkgs = pkgs' // {
inherit crane;
iosevka = pkgs-iosevka.iosevka;
};
in
rec {
defaultPackage = import ./src/engine.nix {
inherit pkgs;
rev = self.rev or "dirty";
content = import ./src/content.nix pkgs;
};
apps = {
render-sketch = utils.lib.mkApp {
drv = import ./src/utils/render-sketch.nix pkgs;
};
};
defaultApp =
let
app = pkgs.writeText "app.py" ''
import http.server
class Server(http.server.ThreadingHTTPServer):
def finish_request(self, request, client_address):
self.RequestHandlerClass(
request,
client_address,
self,
directory="${defaultPackage}"
)
class Handler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_my_headers()
http.server.SimpleHTTPRequestHandler.end_headers(self)
def send_my_headers(self):
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
self.send_header("Pragma", "no-cache")
self.send_header("Expires", "0")
http.server.test(
ServerClass=Server,
HandlerClass=Handler,
port=3080
)
'';
in
utils.lib.mkApp {
drv = pkgs.writeShellScriptBin "run" ''
${pkgs.python3}/bin/python ${app}
'';
};
}
);
}