Repository navigation
fix(make): detect nix in Docker where profile path differs #1217
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,7 +71,7 @@ NIX_USERNAME := $(shell \ | |||||
| else \ | ||||||
| echo "$(shell whoami)"; \ | ||||||
| fi) | ||||||
| NIX_ENV := $(shell . ~/.nix-profile/etc/profile.d/nix.sh 2>/dev/null || echo "not_found") | ||||||
| NIX_ENV := $(shell . ~/.nix-profile/etc/profile.d/nix.sh 2>/dev/null || . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh 2>/dev/null || command -v nix >/dev/null 2>&1 || echo "not_found") | ||||||
|
||||||
| NIX_ENV := $(shell . ~/.nix-profile/etc/profile.d/nix.sh 2>/dev/null || . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh 2>/dev/null || command -v nix >/dev/null 2>&1 || echo "not_found") | |
| NIX_ENV = $(shell command -v nix >/dev/null 2>&1 || echo "not_found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
command -v nix >/dev/null 2>&1check, while useful for detecting thenixexecutable, only verifies its presence in the PATH. Unlike sourcing the profile scripts (. ~/.nix-profile/...or. /nix/var/nix/profiles/...), it does not ensure that the necessary Nix environment variables (likeNIX_PATH) are correctly set up. If only this check succeeds, theNIX_ENVvariable will be empty, which thenix-checktarget interprets as a functional Nix environment. This could lead to subsequent Nix commands failing due to an incomplete environment setup, even thoughnix-checkpasses.To make this fallback more robust, consider replacing
command -v nix >/dev/null 2>&1with a check that also verifies basic Nix functionality, such asnix --version >/dev/null 2>&1. This would ensure that ifnixis found, it is also capable of executing basic commands, implying a more complete environment.