nixwebr.ing/site/default.nix

46 lines
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
id = replaceStrings [" " ";"] ["-" "-"] (toLower content);
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 = "/"; }
{ 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
];
}