From 097307c46fc5a7bda63a5916cfd1ee3ad661a0a6 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Wed, 25 Jul 2018 03:11:41 +0200 Subject: pkgs/profpatsch: WIP execline experiments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * runExecline: like runCommand, but a lot more lightweight * symlink: symlink a given list of links together * importer: a small DSL to “import” “modules” into a build context Some highlights: * runExecline does not use any stdenv (apart from the `execline` build) * symlink uses netstrings to pass correct fields into the derivation * no use of bash, everything uses execline. --- pkgs/profpatsch/execline/run-execline.nix | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pkgs/profpatsch/execline/run-execline.nix (limited to 'pkgs/profpatsch/execline/run-execline.nix') diff --git a/pkgs/profpatsch/execline/run-execline.nix b/pkgs/profpatsch/execline/run-execline.nix new file mode 100644 index 00000000..40915f25 --- /dev/null +++ b/pkgs/profpatsch/execline/run-execline.nix @@ -0,0 +1,38 @@ +{ stdenv, importasCommand, execlinebCommand }: +{ name +# the execline script +, execline +# additional arguments to pass to the derivation +, derivationArgs ? {} +}: + +# those arguments can’t be overwritten +assert !derivationArgs ? system; +assert !derivationArgs ? name; +assert !derivationArgs ? builder; +assert !derivationArgs ? args; + +derivation (derivationArgs // { + inherit (stdenv) system; + inherit name; + + # okay, `builtins.toFile` does not accept strings + # that reference drv outputs. This means we need + # to pass the script as envvar; + # this might clash with another passed envar, + # so we give it a long & unique name + _runExeclineScript = execline; + passAsFile = [ "_runExeclineScript" ] + ++ derivationArgs.passAsFile or []; + + builder = importasCommand; + args = [ + "-ui" # drop the envvar afterwards + "script" # substitution name + "_runExeclineScriptPath" # passed script file + execlinebCommand # the actual invocation + "-P" # ignore command line arguments + "-W" # die on syntax error + "$script" # substituted by importas + ]; +}) -- cgit 1.4.1