diff options
Diffstat (limited to 'pkgs/profpatsch/nix-tools.nix')
-rw-r--r-- | pkgs/profpatsch/nix-tools.nix | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/pkgs/profpatsch/nix-tools.nix b/pkgs/profpatsch/nix-tools.nix index 557e6680..e0b20318 100644 --- a/pkgs/profpatsch/nix-tools.nix +++ b/pkgs/profpatsch/nix-tools.nix @@ -1,13 +1,36 @@ -{ pkgs, writeExecline, runblock, getBins }: +{ pkgs, writeExecline, getBins, runblock }: let bins = getBins pkgs.nix [ "nix-build" "nix-instantiate" ]; + # Usage (execline syntax): + # nix-run { -A foo <more_nix_options> } args... + # + # Takes an execline block of `nix-build` arguments, which should produce an executable store path. + # Then runs the store path with `prog...`. nix-run = writeExecline "nix-run" { argMode = "env"; } [ "backtick" "-iE" "storepath" [ runblock "1" bins.nix-build ] - runblock "-r" "2" "exec" "$storepath" + runblock "-r" "2" "$storepath" + ]; + + # Usage (execline syntax): + # nix-run-bin { -A foo <more_nix_options> } <foo_bin_name> args... + # + # Takes an execline block of `nix-build` arguments, which should produce a store path with a bin/ directory in it. + # Then runs the `/bin/<foo_bin_name>` executable in the store path with the given arguments. + nix-run-bin = writeExecline "nix-run-bin" { argMode = "env"; } [ + "backtick" "-i" "storepath" [ + runblock "1" bins.nix-build + ] + runblock "-r" "2" + # workaround, runblock does not set # and $0 and so forth in its blocks (yet) + (writeExecline "nix-run-bin-rest-block" { readNArgs = 1; } [ + "importas" "-ui" "storepath" "storepath" + "if" [ "echo" "\${storepath}/bin/\${1}" ] + "\${storepath}/bin/\${1}" "$@" + ]) ]; nix-eval = writeExecline "nix-eval" {} [ @@ -21,6 +44,7 @@ let in { inherit nix-run + nix-run-bin nix-eval ; } |