From d31fd244af0a73b021b453b80d14e70e9a6dfc2b Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Sat, 25 May 2024 17:25:15 +0200 Subject: [PATCH] move getEntry to extraArgs instead of making the user add it --- engine.nix | 24 ++++++++++-------------- example/default.nix | 5 +---- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/engine.nix b/engine.nix index 796dd16..e0b7b7c 100644 --- a/engine.nix +++ b/engine.nix @@ -8,7 +8,7 @@ pkgs: src: {extraArgs, entries, templates}: let inherit (lib.strings) concatMapStrings concatStrings escapeShellArg hasSuffix isString removeSuffix; inherit (lib.trivial) functionArgs; - args = {inherit pkgs;} + args = {inherit pkgs getEntry;} // (import ./stdlib.nix pkgs) // extraArgs; @@ -84,16 +84,12 @@ pkgs: src: {extraArgs, entries, templates}: let else entry; -in { - inherit getEntry; - - buildScript = /*sh*/'' - ${concatMapStrings - (result: /*sh*/'' - mkdir -p $out/${dirOf result.file} - echo ${escapeShellArg result.output} > $out/${result.file} - '') - (forEach entries processEntryFile) - } - ''; -} +in /*sh*/'' + ${concatMapStrings + (result: /*sh*/'' + mkdir -p $out/${dirOf result.file} + echo ${escapeShellArg result.output} > $out/${result.file} + '') + (forEach entries processEntryFile) + } +'' diff --git a/example/default.nix b/example/default.nix index ea0368a..fd6d5fe 100644 --- a/example/default.nix +++ b/example/default.nix @@ -8,10 +8,7 @@ inherit (lib.lists) map; inherit (lib.strings) replaceStrings toLower; - _nte = nte {inherit extraArgs entries templates;}; - extraArgs = { - inherit (_nte) getEntry; h = n: content: let id = replaceStrings [" " ";"] ["-" "-"] (toLower content); in /*html*/'' @@ -43,7 +40,7 @@ in buildPhase = /*sh*/'' runHook preBuild - ${_nte.buildScript} + ${nte {inherit extraArgs entries templates;}} runHook postBuild '';