fix several function args
This commit is contained in:
parent
40771f288f
commit
fac9a1ef95
2 changed files with 14 additions and 14 deletions
10
engine.nix
10
engine.nix
|
@ -12,16 +12,16 @@ pkgs: src: {extraArgs, entries, templates}: let
|
|||
args' = {inherit pkgs;} // extraArgs;
|
||||
|
||||
args = args' // {
|
||||
applyTemplate = applyTemplate args';
|
||||
applyTemplate = applyTemplate args' templates;
|
||||
findTemplateFn = findTemplateFn templates;
|
||||
getEntry = getEntry args' src;
|
||||
getEntry = getEntry args' templates src;
|
||||
};
|
||||
|
||||
processEntryFile = entryFile: let
|
||||
foundTemplateFn = findTemplateFn templates entry;
|
||||
entry = getEntry args src entryFile;
|
||||
foundTemplateFn = findTemplateFn templates entry.template;
|
||||
entry = getEntry args templates src entryFile;
|
||||
in
|
||||
applyTemplate args foundTemplateFn entry;
|
||||
applyTemplate args templates foundTemplateFn entry;
|
||||
|
||||
in /*sh*/''
|
||||
${concatMapStrings
|
||||
|
|
18
stdlib.nix
18
stdlib.nix
|
@ -24,7 +24,7 @@ pkgs: let
|
|||
else
|
||||
(import template);
|
||||
|
||||
applyTemplate = extraArgs: templateFn: entry: let
|
||||
applyTemplate = extraArgs: templates: templateFn: entry: let
|
||||
template = templateFn ({inherit pkgs;} // extraArgs // entry);
|
||||
in
|
||||
if isBaseTemplate template then {
|
||||
|
@ -33,9 +33,9 @@ pkgs: let
|
|||
}
|
||||
else let
|
||||
newEntry = template.output // {inherit (entry) file;};
|
||||
foundTemplateFn = findTemplateFn newEntry;
|
||||
foundTemplateFn = findTemplateFn templates newEntry.template;
|
||||
in
|
||||
applyTemplate foundTemplateFn newEntry;
|
||||
applyTemplate extraArgs templates foundTemplateFn newEntry;
|
||||
|
||||
replaceSuffix = from: to: string:
|
||||
if !(hasSuffix from string) then
|
||||
|
@ -43,7 +43,7 @@ pkgs: let
|
|||
else
|
||||
concatStrings [ (removeSuffix from string) to ];
|
||||
|
||||
getTemplateFormat = extraArgs: entry: templateFn: let
|
||||
getTemplateFormat = extraArgs: templates: entry: templateFn: let
|
||||
# getEntry needs to go down to the base template for the format
|
||||
# but any template through the way can ask for a file
|
||||
# so we just give it a placeholder - an empty string here
|
||||
|
@ -54,15 +54,15 @@ pkgs: let
|
|||
template.format
|
||||
else let
|
||||
newEntry = template.output;
|
||||
foundTemplateFn = findTemplateFn newEntry;
|
||||
foundTemplateFn = findTemplateFn templates newEntry.template;
|
||||
in
|
||||
getTemplateFormat newEntry foundTemplateFn;
|
||||
getTemplateFormat extraArgs templates newEntry foundTemplateFn;
|
||||
|
||||
getEntry = extraArgs: sourceDir: entryFile: let
|
||||
getEntry = extraArgs: templates: sourceDir: entryFile: let
|
||||
sourceFile = toString (removePrefix sourceDir entryFile);
|
||||
entry = (import entryFile) ({inherit pkgs;} // extraArgs);
|
||||
foundTemplateFn = findTemplateFn entry;
|
||||
entryFormat = getTemplateFormat entry foundTemplateFn;
|
||||
foundTemplateFn = findTemplateFn templates entry.template;
|
||||
entryFormat = getTemplateFormat extraArgs templates entry foundTemplateFn;
|
||||
in
|
||||
if !(hasAttr "file" entry) then
|
||||
entry // {
|
||||
|
|
Loading…
Reference in a new issue