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

Bug: nixStatic has dependencies in /nix/store #262007

Closed
michaelCTS opened this issue Oct 19, 2023 · 3 comments
Closed

Bug: nixStatic has dependencies in /nix/store #262007

michaelCTS opened this issue Oct 19, 2023 · 3 comments
Labels

Comments

@michaelCTS
Copy link
Contributor

michaelCTS commented Oct 19, 2023

Describe the bug

When trying to run nix-channel using the static binary in a virgin, non-nix environment, it fails trying to find nix-env in /nix/store. store = /home/user/my-store in nix.conf is ignored.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Start a virgin, non-nix environment e.g alpine or debian in a VM or docker
  2. Download the static nix binary (or transfer it from your nix environment) (see discourse for attempts at making that easier and [Feature request] Provide static binary on github release page nix#9176; a feature request for easier retrieval)
  3. Create a folder and add it to PATH
  4. Move the nix binary into it and create symlinks to it called nix-channel and nix-env
  5. run nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
  6. run nix-channel --update

Expected behavior

The nixpkgs channel should be downloaded.

Screenshots

$ nix-channel --update
unpacking channels...
error: executing '/nix/store/qibdl14c7jcxna48v5h5g51qm1iw2iw9-nix-static-x86_64-unknown-linux-musl-2.17.0/bin/nix-env': No such file or directory
error: program '/nix/store/qibdl14c7jcxna48v5h5g51qm1iw2iw9-nix-static-x86_64-unknown-linux-musl-2.17.0/bin/nix-env' failed with exit code 1

Additional context

Basically was trying to do what @matthewbauer did https://matthewbauer.us/blog/static-nix.html , but with the official nixStatic. Related PR #56281 which was superseded by #70024

Notify maintainers

@eelco @lovesegfault @Artturin

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here

--> this doesn't work as channels don't work

@michaelCTS michaelCTS added the 0.kind: bug Something is broken label Oct 19, 2023
@Artturin
Copy link
Member

Artturin commented Oct 20, 2023

This is a nix issue, not a nixpkgs one

https://github.com/NixOS/nix/blob/e58566a057692bbfbd30a6639248adfcf81df108/src/nix-channel/nix-channel.cc#L146

there's many usages of runProgram(settings.nixBinDir

Try export NIX_BIN_DIR=$(dirname $(type -p nix))

weirdly the variable is not documented anywhere nor is it mentioned in any issue

https://github.com/search?q=%2F%5CbNIX_BIN_DIR%2F+NOT+is%3Afork&type=code

Maybe the code could be changed to re-execute itself with a different argv0?

@Artturin
Copy link
Member

Artturin commented Oct 20, 2023

Please create a issue in the nix repo and I will repost my comment there.

@Artturin
Copy link
Member

Created NixOS/nix#9193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants