From f53c65286e66177d604462b63cb2e6c9cbbd6d8f Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sat, 8 Jan 2022 18:22:43 +0100 Subject: pkgs/profpatsch/nix-tools/nix-run-bin: use PATH instead If you want to use multiple binaries (e.g. via `pkgs.symlinkJoin`), this will work via PATH instead of magically tranforming the first argument instead. --- pkgs/profpatsch/nix-tools.nix | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkgs/profpatsch/nix-tools.nix b/pkgs/profpatsch/nix-tools.nix index e0b20318..1f2ae89e 100644 --- a/pkgs/profpatsch/nix-tools.nix +++ b/pkgs/profpatsch/nix-tools.nix @@ -19,18 +19,14 @@ let # nix-run-bin { -A foo } 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/` executable in the store path with the given arguments. + # Then runs the given command line with the given arguments. All executables in the built storepath’s bin directory are prepended to `PATH`. nix-run-bin = writeExecline "nix-run-bin" { argMode = "env"; } [ - "backtick" "-i" "storepath" [ + "backtick" "-iE" "storepath" [ runblock "1" bins.nix-build ] + "importas" "-ui" "PATH" "PATH" + "export" "PATH" "\${storepath}/bin:\${PATH}" 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" {} [ -- cgit 1.4.1