diff options
author | Andreas Schmid <service@aaschmid.de> | 2021-02-28 08:30:34 +0100 |
---|---|---|
committer | Andreas Schmid <service@aaschmid.de> | 2021-03-03 08:49:32 +0100 |
commit | d81d591d13df3d609b8fa05695882edce3a91244 (patch) | |
tree | 3c4b6fcc32a67a88a0858191bfb3fa1f29802288 | |
parent | 7fd33568097fb72194bafc6016d4803cf125d36f (diff) |
nix-direnv: fix NIX_BIN_PREFIX substitution in built direnvrc
* Reason: statically set `${NIX_BIN_PREFIX}` within generated `direnvrc`. * Before it only replaced the `-z ${NIX_BIN_PREFIX:-}` check which therefore never was `true`. So, also `NIX_BIN_PREFIX` never got set such that its usage later always failed execution with `NIX_BIN_PREFIX: unbound variable`. With the fix, the line containing the check will no longer be replaced. * Solves https://github.com/nix-community/nix-direnv/issues/70 * See also discussion on #114622 Signed-off-by: Andreas Schmid <service@aaschmid.de>
-rw-r--r-- | pkgs/tools/misc/nix-direnv/default.nix | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/pkgs/tools/misc/nix-direnv/default.nix b/pkgs/tools/misc/nix-direnv/default.nix index 833f8313f6172..3fe8e3f387024 100644 --- a/pkgs/tools/misc/nix-direnv/default.nix +++ b/pkgs/tools/misc/nix-direnv/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, gnugrep, nix }: +{ lib, stdenv, fetchFromGitHub, gnugrep, nix, nixFlakes }: stdenv.mkDerivation rec { pname = "nix-direnv"; @@ -14,9 +14,8 @@ stdenv.mkDerivation rec { # Substitute instead of wrapping because the resulting file is # getting sourced, not executed: postPatch = '' - substituteInPlace direnvrc \ - --replace "\''${NIX_BIN_PREFIX:-}" "\''${NIX_BIN_PREFIX:-${nix}/bin/}" \ - --replace "grep" "${gnugrep}/bin/grep" + sed -i "1a NIX_BIN_PREFIX=${nixFlakes}/bin/" direnvrc + substituteInPlace direnvrc --replace "grep" "${gnugrep}/bin/grep" ''; installPhase = '' |