-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.nix
More file actions
40 lines (36 loc) · 1.51 KB
/
build.nix
File metadata and controls
40 lines (36 loc) · 1.51 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
{ pkgs, h }:
let
flakeSrc = builtins.readFile ./flake.nix;
buildSrc = builtins.readFile ./build.nix;
css = ''
body { max-width: 800px; margin: 2rem auto; padding: 0 1rem; font-family: system-ui; background: #fafafa; color: #333; }
@media (prefers-color-scheme: dark) { body { background: #1a1a2e; color: #eee; } }
h1 { border-bottom: 2px solid #0066cc; padding-bottom: 0.5rem; }
h2 { color: #666; margin-top: 1.5rem; font-size: 1rem; font-family: ui-monospace, monospace; }
@media (prefers-color-scheme: dark) { h2 { color: #999; } }
pre { background: #1a1a2e; color: #eee; padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: 0.85rem; line-height: 1.4; }
code { font-family: ui-monospace, monospace; }
.meta { color: #666; font-style: italic; margin-top: 2rem; }
@media (prefers-color-scheme: dark) { .meta { color: #888; } }
'';
page = h.render [
"html" { lang = "en"; }
[ "head"
[ "meta" { charset = "utf-8"; } ]
[ "meta" { name = "viewport"; content = "width=device-width, initial-scale=1"; } ]
[ "title" "Quine - niccup example" ]
[ "style" (h.raw css) ]
]
[ "body"
[ "h1" "This page was generated by:" ]
[ "h2" "flake.nix" ]
[ "pre" [ "code" flakeSrc ] ]
[ "h2" "build.nix" ]
[ "pre" [ "code" buildSrc ] ]
[ "p.meta" "Copy both files, run 'nix build', and you'll get this exact page." ]
]
];
in pkgs.runCommand "quine" {} ''
mkdir -p $out
cp ${pkgs.writeText "index.html" page} $out/index.html
''