feat: add web host

This commit is contained in:
Katharina Heidenreich 2026-03-16 19:57:27 +01:00
parent df9367d12f
commit 155801244a
3 changed files with 63 additions and 1 deletions

34
data/web.nix Normal file
View file

@ -0,0 +1,34 @@
let
lib = import <nixpkgs/lib>;
mapFileNameToContent = fileName: {
status = 200;
contentType = "text/html";
content = builtins.readFile fileName;
};
findFiles = dir:
let content = builtins.readDir dir;
processEntry = name: type:
if type == "directory" then
findFiles (dir + "/${name}")
else if type == "regular" then
[ (dir + "/${name}") ]
else
[];
in
lib.concatLists (lib.mapAttrsToList processEntry content);
removePrefix = str: prefix: if builtins.substring 0 (builtins.stringLength prefix) str == prefix
then builtins.substring (builtins.stringLength prefix) (builtins.stringLength str - builtins.stringLength prefix) str
else str;
contentFn = basePath:
let
files = findFiles basePath;
baseLength = builtins.stringLength basePath;
files' = builtins.filter (file: builtins.match ".*\\.html$" file != null) files;
in builtins.listToAttrs (map (file: {
name = removePrefix file basePath;
value = mapFileNameToContent file;
}) files');
in
rec {
"nudelerde.de" = contentFn "/etc/nixos/data/web/";
}

11
data/web/index.html Normal file
View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Hii :3</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
</head>
<body>
Hiiii :3
</body>
</html>