2021-08-25 02:45:12 +02:00
|
|
|
{ depot, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (depot.users.sterni.nix.html)
|
|
|
|
__findFile
|
|
|
|
esc
|
|
|
|
withDoctype
|
|
|
|
;
|
|
|
|
|
|
|
|
exampleDocument = withDoctype (<html> { lang = "en"; } [
|
2022-01-30 17:06:58 +01:00
|
|
|
(<head> { } [
|
2021-08-25 02:45:12 +02:00
|
|
|
(<meta> { charset = "utf-8"; } null)
|
2022-01-30 17:06:58 +01:00
|
|
|
(<title> { } "html.nix example document")
|
|
|
|
(<link>
|
|
|
|
{
|
|
|
|
rel = "license";
|
|
|
|
href = "https://code.tvl.fyi/about/LICENSE";
|
|
|
|
type = "text/html";
|
|
|
|
}
|
|
|
|
null)
|
|
|
|
(<style> { } (esc ''
|
2021-08-25 02:45:12 +02:00
|
|
|
hgroup h2 {
|
|
|
|
font-weight: normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
dd {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
''))
|
|
|
|
])
|
2022-01-30 17:06:58 +01:00
|
|
|
(<body> { } [
|
|
|
|
(<main> { } [
|
|
|
|
(<hgroup> { } [
|
|
|
|
(<h1> { } (esc "html.nix"))
|
|
|
|
(<h2> { } [
|
|
|
|
(<em> { } "the")
|
2021-08-25 02:45:12 +02:00
|
|
|
(esc " most cursed HTML DSL ever!")
|
|
|
|
])
|
|
|
|
])
|
2022-01-30 17:06:58 +01:00
|
|
|
(<dl> { } [
|
|
|
|
(<dt> { } [
|
2021-08-25 02:45:12 +02:00
|
|
|
(esc "Q: Wait, it's all ")
|
2022-01-30 17:06:58 +01:00
|
|
|
(<a>
|
|
|
|
{
|
|
|
|
href = "https://cl.tvl.fyi/q/hashtag:cursed";
|
|
|
|
}
|
|
|
|
(esc "cursed"))
|
2021-08-25 02:45:12 +02:00
|
|
|
(esc " nix hacks?")
|
|
|
|
])
|
2022-01-30 17:06:58 +01:00
|
|
|
(<dd> { } (esc "A: Always has been. 🔫"))
|
|
|
|
(<dt> { } (esc "Q: Why does this work?"))
|
|
|
|
(<dd> { } [
|
2021-08-25 02:45:12 +02:00
|
|
|
(esc "Because nix ")
|
2022-01-30 17:06:58 +01:00
|
|
|
(<a>
|
|
|
|
{
|
|
|
|
href = "https://github.com/NixOS/nix/blob/293220bed5a75efc963e33c183787e87e55e28d9/src/libexpr/parser.y#L410-L416";
|
|
|
|
}
|
|
|
|
(esc "translates "))
|
|
|
|
(<a>
|
|
|
|
{
|
|
|
|
href = "https://github.com/NixOS/nix/blob/293220bed5a75efc963e33c183787e87e55e28d9/src/libexpr/lexer.l#L100";
|
|
|
|
}
|
|
|
|
(esc "SPATH tokens"))
|
2021-08-25 02:45:12 +02:00
|
|
|
(esc " like ")
|
2022-01-30 17:06:58 +01:00
|
|
|
(<code> { } (esc "<nixpkgs>"))
|
2021-08-25 02:45:12 +02:00
|
|
|
(esc " into calls to ")
|
2022-01-30 17:06:58 +01:00
|
|
|
(<code> { } (esc "__findFile"))
|
2021-08-25 02:45:12 +02:00
|
|
|
(esc " in the ")
|
2022-01-30 17:06:58 +01:00
|
|
|
(<em> { } (esc "current"))
|
2021-08-25 02:45:12 +02:00
|
|
|
(esc " scope.")
|
|
|
|
])
|
|
|
|
])
|
|
|
|
])
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
in
|
|
|
|
|
2022-09-26 19:33:05 +02:00
|
|
|
pkgs.runCommand "html.nix.html"
|
2022-01-30 17:06:58 +01:00
|
|
|
{
|
2021-08-25 02:45:12 +02:00
|
|
|
passAsFile = [ "exampleDocument" ];
|
|
|
|
inherit exampleDocument;
|
|
|
|
nativeBuildInputs = [ pkgs.html5validator ];
|
|
|
|
} ''
|
|
|
|
set -x
|
|
|
|
test "${esc "<> && \" \'"}" = "<> && " '"
|
|
|
|
|
|
|
|
# slow as hell unfortunately
|
|
|
|
html5validator "$exampleDocumentPath"
|
|
|
|
|
|
|
|
mv "$exampleDocumentPath" "$out"
|
|
|
|
|
|
|
|
set +x
|
|
|
|
''
|