Nixos-shell in nixos vm does not seem to be recognizing store paths?

I’m using GitHub - Mic92/nixos-shell: Spawns lightweight nixos vms in a shell to build/run a VM.

Within this VM, I try run nixos-shell which initially failed with an error however after adding:

{...}: {
  nix.nixPath = [
    "nixpkgs=${pkgs.path}"
  ];
}


It now works, however it seems to be downloading dependencies that should already exist in the host, when trying to invoke something via nix-shell .

nix-shell -p vim                                                                                       /bambie
these paths will be fetched (7.00 MiB download, 33.13 MiB unpacked):
  /nix/store/1cbk7i6dg26cygss2b6w8xq4dnj50z31-vim-8.2.1522
copying path '/nix/store/1cbk7i6dg26cygss2b6w8xq4dnj50z31-vim-8.2.1522' from 'https://cache.nixos.org'...
^Cerror: interrupted by the user

why this error happen ,can anyone help?

is this possibly related to the vm using a different channel to the host.

as mentioned here.GitHub - Mic92/nixos-shell: Spawns lightweight nixos vms in a shell

double check the channels. I first found channels confusing, espically when you can mix and match channels and have per users channels too, maximum flexibility and maximum confusion.

what was the first error you got? did it download and update the channel, thus you VM is on a more advance channel than the host?

Channels/NIX_PATH

By default VMs will have a NIX_PATH configured for nix channels but no channel are downloaded yet. To avoid having to download a nix-channel every time the VM is reset, you can use the following nixos configuration:

{...}: {
  nix.nixPath = [
    "nixpkgs=${pkgs.path}"
  ];
}
1 Like