1
0
Fork 0
selfhostblocks/lib/default.nix

14 lines
384 B
Nix
Raw Normal View History

2024-02-10 05:56:26 +01:00
{ lib }:
{
template = file: newPath: replacements:
let
templatePath = newPath + ".template";
sedPatterns = lib.strings.concatStringsSep " " (lib.attrsets.mapAttrsToList (from: to: "-e \"s|${from}|${to}|\"") replacements);
in
''
ln -fs ${file} ${templatePath}
rm ${newPath} || :
sed ${sedPatterns} ${templatePath} > ${newPath}
'';
}