{ self, ... }: { perSystem = { ... }: { websites.${self.domain} = { config, lib, ... }: let inherit (lib) mkOption types; root = ./html; files = with lib.fileset; toList (difference (fileFilter (file: file.hasExt "html") root) ./html/Kalender); replacements = { "@title@" = config.title; "@stylesheet@" = ''''; "@head@" = '' ''; "@past-events@" = with lib; let as-list = mapAttrsToList (name: value: { start = value.date.start + value.time.start; value = toString value; }) config.events; sorted = sortOn (event: event.start) as-list; in ''
${concatMapStringsSep "\n" (event: event.value) sorted}
''; }; replace = file: with lib; replaceStrings (attrNames replacements) (attrValues replacements) file; in { title = "Stadtteilbeirat Heimfeld"; events = with lib; listToAttrs ( map (file: { name = removeSuffix ".nix" (toString (baseNameOf file)); value = import file; }) (fileset.toList ./termine) ); files = with lib; listToAttrs ( map (path: { name = lib.path.removePrefix root path; value = with builtins; toFile (baseNameOf path) (replace (readFile path)); }) files ); }; }; }