Version of nixpkgs of nix-shell when using Flakes

I’m using NixOS-Unstable with Flakes as my system. After the last update (yesterday) I saw a package (python3-gdcm) I’m using needs to be compiled, because of a bug with CMake GDCM is not compiling. But if I create a shell environment using nix-shell there is not this problem with GDCM and it’s not necessary to compile GDCM too:

nix-shell -p 'python3.withPackages (ps: with ps; [ gdcm ])'

That indicates me that the nixpkgs of nix-shell is not the same of my system. If I force nix-shell to use the same version of my system, it tries to compile GDCM but it’s not being compiled because of that Cmake bug:

nix-shell -p 'python3.withPackages (ps: with ps; [ gdcm ])' -I nixpkgs=

My question is: what version of nixpkgs nix-shell uses? Why it’s different?

Not a full answer to your question (I don’t understand the exact mechanics myself), but I noticed the same thing and I found these two lines that seemed to fix the issue (not my config): nixos-config.nix · f1f8624c14920407c39bbeeb0e4c0397ea25e980 · sebastien.rey-coyrehourcq / Dotfiles · GitLab . For me it was using some nixos channel in the NIX_PATH before.

1 Like

Yes, you are correct, the nixpkgs used by nix-shell is the one defined by NIX_PATH. One way to do it in the flake is like this:

If you are using the nix shell nixpkgs#... version, then you can configure what the nixpkgs registry refers to like this:

To answer what version of nixpkgs is used, check the content of NIX_PATH.


Thanks @SFrijters and @terlar! It worked. One more question … My configurations are here GitHub - tfmoraes/nixoscfg, inside the flake.nix I’m importing my nixos-config. nixos-config has 2 parameters (config and pkgs) and .... If I want pass more parameters how do I do? I tried to just add, for instance, inputs as parameter but it didn’t work.

I pass inputs to my nixos configurations via specialArgs:

1 Like

Thanks @colemickens, it worked! I just added specialArgs = { inherit inputs; }; and it it worked.