DavHau / nix-portable

Nix - Static, Permissionless, Installation-free, Pre-configured
MIT License
870 stars 31 forks source link

Ability to simply enter the sandbox #108

Open pbsds opened 5 months ago

pbsds commented 5 months ago

I would love if nix-portable could simply drop me into the sandbox (in my case bwrap) where the store and in turn nix profile are available, without going via a nix derivation. nix-portable nix run nixpkgs#bash will fetch the newest nixpkgs version, and then build bash, causing me to have to wait, while nix-portable nix-shell -p bash both changes the ps1 and will require me to update the channel every now and then.

my current workaround/illegal incantation:

nix-portable ../../../../../../../../../../../../../"$(command -v "$SHELL")"

and in .bashrc/.profile:

if test -d $HOME/.nix-profile/bin; then
    export PATH="$HOME/.nix-profile/bin:$PATH"
fi
chaserhkj commented 4 months ago

You can pin a version of nixpkgs so that it is used every time:

nix-portable nix registry pin nixpkgs

After this nix-portable nix run should always use the version you pinned. You can use nix registry to change the pin as well.

pbsds commented 4 months ago

I found that entering a nix bash shell caused everything sourced from /etc/skel to fail, where a lot of the SLURM logic is set up on this host. Here I explicitly want to enter the bwrap without neccesarily entering a nix shell

nesqi commented 1 month ago

I would also like to be able to just drop into the sandbox.

In my case I don't even have the flake on the machine I'm running nix-portable on. Instead I do a 'nix copy' to that host and 'nix profile install' to access the binaries. But since the profiles are in /nix I need to be in the sandbox to access it. It seems possible to get a shell by running 'nix-portable nix-shell -p', but it feels like a hack.