5 map = f: list: builtins.concatStringsSep "" (builtins.map f list);
8 mkTemplates = name: templatesDir: templates:
10 templatesDrv = pkgs.runCommand "${name}-templates" { } ''
12 for t in ${templatesDir}/**/*; do
13 subdir=$(dirname "$t" | cut -d'/' -f5-)
17 mkdir -p "$out/$subdir"
19 echo "{lib, ...}@args: '''" | cat - "$t" > "$out/$subdir/$name.nix" &&
20 echo "'''" >> "$out/$subdir/$name.nix"
23 templateCache = builtins.listToAttrs (builtins.map (t: {
25 value = (import "${templatesDrv}/${t}.nix");
28 ((builtins.getAttr template templateCache)
29 ({ lib = templateLib; } // args));