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