Starting nix-shell without rebuilding

Hello,

I have some nix shells for python with tensorflow, openCV, CUDA. It takes ages to build. I like keeping my system up to date so I update channels often, but unlike nix-shell, that doesn’t stop me from using previous versions of software until build is completed (or often deferred to be done over night).

I might have updated the system days before and only next time I want to urgently use my shell I end up waiting for hours to get back my development environment…

Cannot find how to use cached version of the shell anywhere or to stop it from updating in any way.
Could someone advise how I should organise my work to avoid that issue?

where can we see these nix ‘shells’.

https://nixos.wiki/wiki/Storage_optimization#Pinning

https://www.reddit.com/r/NixOS/comments/r6tsrv/comment/hmyi67a/

3 Likes

Fantastic, didn’t know about this command, thanks!

@rofrol I think this page isn’t explanatory enough for me. It doesn’t explain how nix-instantiate can be used with shell apart form one example command that doesn’t really work for me, $ nix-instantiate shell.nix --indirect --add-root ./.nix-gc-roots/shell.drv ... is looking for a file default.nix which isn’t relevant I believe.
I tried running what I understood should create build outputs in a directory not to be garbage collected:
nix-instantiate tf-shell-new.nix --indirect --add-root ./shellbuilds
However on running nix-shell tf-shell-new.nix it still gets any new packages.

I know that I can pin the shell to specific git revision of nixos, but this is not what I’m looking for.

@nixinator here is my shell: https://github.com/mixmixmix/config/blob/ae71441c1a80d9e4b4f144a26f2993d9f6300a17/mix_shells/tf-shell-new.nix

Any further help appreciated.

Maybe this GitHub - nix-community/nix-direnv: A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10] or Introducing lorri, your project's nix-env

thanks for shell, i’ve been delayed getting back to you, ‘because’.

I presume you have reviewed this issue and tried the solutions out there?

https://github.com/NixOS/nix/issues/2208

may work, may not, things evolve fast around here.