replace getDirectory with builtins.dirOf

This commit is contained in:
jacekpoz 2024-05-25 01:49:33 +02:00
parent b3c4693262
commit b837ac9be5
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -1,20 +1,15 @@
pkgs: {extraArgs, entries, templates}: let
inherit (pkgs) lib;
inherit (builtins) abort;
inherit (lib.lists) elemAt forEach findFirst length remove;
inherit (lib.strings) concatMapStrings concatStrings escapeShellArg isString splitString;
inherit (builtins) abort dirOf;
inherit (lib.lists) forEach findFirst;
inherit (lib.strings) concatMapStrings concatStrings escapeShellArg isString;
inherit (lib.trivial) functionArgs;
args = {inherit pkgs;}
// (import ./stdlib.nix pkgs)
// extraArgs;
getDirectory = file: let
splitPath = splitString "/" file;
last = elemAt splitPath ((length splitPath) - 1);
in
concatStrings (remove last splitPath);
findTemplateFile = entry:
findFirst (templateFile: let
@ -56,7 +51,7 @@ pkgs: {extraArgs, entries, templates}: let
in /*sh*/''
${concatMapStrings
(result: /*sh*/''
mkdir -p $out/${getDirectory result.file}
mkdir -p $out/${dirOf result.file}
echo ${escapeShellArg result.output} > $out/${result.file}
'')
(forEach entries processEntryFile)