-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The nix
command refers to the system wide nix instead of the locally included one
#52
Comments
I have the exact opposite issue, namely that nix-direnv does not use the system Nix which could be Lines 9 to 14 in fd48b56
I think there ought to be a switch. |
Yes, these are two sides of the same problem, namely that different versions of And yes, a flag would be useful. In my local fork I've replaced |
For my use-case it's just the other way around and self: super: {
nix-direnv = super.nix-direnv.overrideAttrs ({ postPatch, ... }: {
postPatch = builtins.replaceStrings
[ "${self.nix}" ] [ "${self.nixFlakes}" ] postPatch;
});
} For your use-case you could also use and overlay which would look like this: self: super: {
nix-direnv = super.nix-direnv.overrideAttrs ({ postPatch, ... }: {
postPatch = postPatch + ''
substituteInPlace direnvrc \
--replace "nix print-dev-env" "${self.nixFlakes}/bin/nix print-dev-env"
'';
});
} |
Maybe direnvrc could be made more patch friendly, but I would prefer if it still works without the package. For |
Actually this overlay was pretty stupid. It's much easier than that. self: super: {
nix-direnv = super.nix-direnv.override { nix = self.nixFlakes; };
} To solve @anka-213's issue, may I suggest the following change to the expression in nixpkgs? diff --git a/pkgs/tools/misc/nix-direnv/default.nix b/pkgs/tools/misc/nix-direnv/default.nix
index 392de7d1bd9..58b92e884cb 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";
@@ -16,6 +16,7 @@ stdenv.mkDerivation rec {
postPatch = ''
substituteInPlace direnvrc \
--replace "grep" "${gnugrep}/bin/grep" \
+ --replace "nix print-dev-env" "${nixFlakes}/bin/nix print-dev-env" \
--replace "nix-shell" "${nix}/bin/nix-shell" \
--replace "nix-instantiate" "${nix}/bin/nix-instantiate"
''; This can then still be overridden by self: super: {
nix-direnv = super.nix-direnv.override { nixFlakes = self.nix; };
} |
At this point we might switch to |
That would solve my use-case, I want to use diff --git a/pkgs/tools/misc/nix-direnv/default.nix b/pkgs/tools/misc/nix-direnv/default.nix
index 392de7d1bd9..46b7d3e803f 100644
--- a/pkgs/tools/misc/nix-direnv/default.nix
+++ b/pkgs/tools/misc/nix-direnv/default.nix
@@ -1,5 +1,11 @@
-{ lib, stdenv, fetchFromGitHub, gnugrep, nix }:
+{ lib, stdenv, fetchFromGitHub, gnugrep, nix, configure ? {} }:
+let
+ nixCmd = cmd:
+ if configure ? ${cmd}
+ then "${configure.${cmd}}/bin/${cmd}"
+ else "${nix}/bin/${cmd}";
+in
stdenv.mkDerivation rec {
pname = "nix-direnv";
version = "1.2";
@@ -16,8 +22,9 @@ stdenv.mkDerivation rec {
postPatch = ''
substituteInPlace direnvrc \
--replace "grep" "${gnugrep}/bin/grep" \
- --replace "nix-shell" "${nix}/bin/nix-shell" \
- --replace "nix-instantiate" "${nix}/bin/nix-instantiate"
+ --replace "nix print-dev-env" "${nixCmd "nix print-dev-env"}" \
+ --replace "nix-shell" "${nixCmd "nix-shell"}" \
+ --replace "nix-instantiate" "${nixCmd "nix-instantiate"}"
'';
installPhase = '' and then self: super: {
nix-direnv = super.nix-direnv.override {
configure = {
"nix print-dev-env" = self.nixFlakes;
};
};
} |
BTW, Another candidate with the same problem is Something like this would be addressed by Gentoo-like USE flags (see NixOS/nixpkgs#56227) but Eelco doesn't seem to like this at all. |
Fix in #59 |
There are plans to have module system for packages, which would be more powerful than USE flags. |
In
default.nix
, most references to programs are replaced, but not thenix
executable. If that would refer tonixpkgs.nixFlakes
, then you could useuse flakes
without having the beta version of nix installed globally.Warning: Don't try
--replace "nix" "${nix}/bin/nix" \
like did first, since that is bound to end badly.The text was updated successfully, but these errors were encountered: