nixwebr.ing/site/default.nix

47 lines
1.1 KiB
Nix
Raw Normal View History

2024-09-13 20:08:41 +02:00
{
jetbrains-mono,
lib,
mkNteDerivation,
2024-09-13 21:38:59 +02:00
webringMembers,
writeText,
2024-09-13 20:08:41 +02:00
...
}: let
inherit (lib.attrsets) listToAttrs;
inherit (lib.lists) map;
inherit (lib.strings) replaceStrings toLower;
h = n: content: let
2024-09-14 22:53:32 +02:00
id = replaceStrings [" " ";" "?"] ["-" "-" ""] (toLower content);
2024-09-13 20:08:41 +02:00
in /*html*/''
<h${toString n} id="${id}"><a href="#${id}">#</a> ${content}</h${toString n}>
'';
2024-09-13 21:38:59 +02:00
hs = listToAttrs (map (n: {
name = "h${toString n}";
value = text: h n text;
}) [ 1 2 3 4 5 6 ]);
2024-09-13 20:08:41 +02:00
in mkNteDerivation {
name = "nix-webring-site";
version = "0.1.0";
src = ./.;
2024-09-13 21:38:59 +02:00
extraArgs = hs // {
inherit h webringMembers;
};
2024-09-13 20:08:41 +02:00
entries = [
./index.nix
];
extraFiles = [
{ source = "./index.css"; destination = "/"; }
{ source = "./nix-webring.svg"; destination = "/"; }
2024-09-14 00:04:03 +02:00
{ source = "./nix.svg"; destination = "/"; }
2024-09-13 20:08:41 +02:00
{ source = "${jetbrains-mono}/share/fonts/truetype/JetBrainsMono-Regular.ttf"; destination = "/"; }
2024-09-13 21:38:59 +02:00
{
source = writeText "webring.json" (builtins.toJSON webringMembers);
destination = "/webring.json";
}
2024-09-13 20:08:41 +02:00
];
}