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=https://github.com/NixOS/nixpkgs/archive/83cbad92d73216bb0d9187c56cce0b91f9121d5a.tar.gz

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:
https://github.com/terlar/nix-config/blob/3b40387963f8eccfbd9d9dac7296685bb013e6e0/flake.nix#L116-L117

If you are using the nix shell nixpkgs#... version, then you can configure what the nixpkgs registry refers to like this:
https://github.com/terlar/nix-config/blob/3b40387963f8eccfbd9d9dac7296685bb013e6e0/flake.nix#L122-L122

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

3 Likes

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: https://github.com/colemickens/nixcfg/blob/105ae18296915eec45e1a2bf9b183fa4890f3924/flake.nix#L75-L80

1 Like

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