# Pastebin UJrJVs3n partialPaths = { header-navigation = ./templates/header-navigation.html; footer-navigation = ./templates/footer-navigation.html; footer = ./templates/footer.html; links = ./templates/links.html; }; mkTemplate = path: let name = (builtins.replaceStrings [ (toString ./.) "/" ] [ "" "__" ] (toString path)); in writeText "template" '' { partials, ... }@args: ''' ${lib.fileContents path} ''' ''; evalTemplate = { layout, src ? null, ... }@args: import (mkTemplate layout) (args // { partials = lib.mapAttrs (k: v: evalTemplate (args // { layout = v; })) partialPaths; body = if src != null then evalTemplate (args // { layout = src; }) else ""; }); mkPage = { name ? "page", route, src, layout ? null, ... }@args: let result = writeText route (evalTemplate (args // { inherit layout src; })); in stdenv.mkDerivation { inherit name; buildCommand = '' mkdir -p $out ln -s ${result} $out/${route} ''; };