Skip to content
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

Fix Nix detection #773

Merged
merged 1 commit into from
Feb 14, 2022
Merged

Fix Nix detection #773

merged 1 commit into from
Feb 14, 2022

Conversation

veehaitch
Copy link
Contributor

Detect Nix by probing for the presence of the NIX_STORE environment
variable instead of NIX_PATH. The latter is only set in a nix-shell
session but isn't when building a derivation through nix-build. In
contrast, the NIX_STORE environment variable is set in both cases.

Companion PR to intel/intel-sgx-ssl#111

Signed-off-by: Vincent Haupert mail@vincent-haupert.de

@veehaitch veehaitch changed the title Linux: fix Nix detection Fix Nix detection Jan 11, 2022
Detect Nix by probing for the presence of the `NIX_STORE` environment
variable instead of `NIX_PATH`. The latter is only set in a `nix-shell`
session but isn't when building a derivation through `nix-build`. In
contrast, the `NIX_STORE` environment variable is set in both cases.

Signed-off-by: Vincent Haupert <mail@vincent-haupert.de>
@veehaitch
Copy link
Contributor Author

Following a discussion in intel/intel-sgx-ssl#111 with @jinghe-INTC, we should merge this PR first.

A short demonstration of $NIX_PATH VS. $NIX_STORE:

Within a nix-shell environment (the way this repository uses Nix):

# nix-shell -p gcc --pure --command "env | grep -E 'NIX_PATH|NIX_STORE'"
NIX_STORE=/nix/store

Within a nix-build (a sandboxed build environment; preferred approach):

# cat default.nix
with import <nixpkgs> { };
runCommand "test-env" { } ''
  env | grep -E 'NIX_PATH|NIX_STORE'
  mkdir $out
''
# nix-build default.nix
NIX_STORE=/nix/store

Please let me know if there's anything I can do to advance this PR, @lzha101. Happy to help!

@lzha101 lzha101 merged commit f607f89 into intel:master Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants