1

I'm trying to install this Python library python3.6-geopandas-0.3.0. And I successfully installed it imperatively with

$ nix-env -iA nixpkgs.python3Packages.geopandas

However I need to create an expression so that my Python environment includes it.

with import <nixpkgs> {};

python36.withPackages (ps: with ps; [
  geopandas
])

Turns out I get

installing ‘python3-3.6.4-env’
error: undefined variable ‘geopandas’

I have both nixos and nixpkgs-unstable configured in my system. Not sure if correctly though. I have channel nixos for root and nixpkgs for my user.

$ echo $NIX_PATH 
nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels

I would like to make nixpkgs-unstable the default channel for my user, or at least make its packages visible as an overlay, so I could run the above expression successfully.

closed as unclear what you're asking by Wildcard, G-Man, X Tian, Archemar, Rui F Ribeiro Feb 17 '18 at 17:09

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

Your expression works for me on current nixpkgs master. I would investigate if your NIX_PATH isn't taking some old <nixpkgs> that you didn't expect, e.g. geopandas isn't present on the 17.09 stable branch.

  • $ echo $NIX_PATH nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels – dmvianna Feb 16 '18 at 11:08
  • I would like to use stable in root and unstable in the user environment. Is that possible? – dmvianna Feb 18 '18 at 9:32
2

I was able to reproduce this on NixOS.

Your NIX_PATH sets nixpkgs to /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs which if you look up is just a symlink to /nix/var/nix/profiles/per-user/root/channels/nixos/. It's probably a little hack to make work all the expressions that are in the wild that expect <nixpkgs> to point to a valid channel path (even though I don't think it's a requirement for a nix system and seems to originate from nix-daemon).

To fix it you either have to redefine NIX_PATH to point to an actual nixpkgs channel or you have to explicitly state the path to the channel instead of using <nixpkgs> in your expression.

You can find your available channels in ~/.nix-defexpr:

$tree -l -L 2 ~/.nix-defexpr/
/home/user1/.nix-defexpr/
├── channels -> /nix/var/nix/profiles/per-user/user1/channels
│   ├── ...
│   └── nixpkgs -> /nix/store/qz1.../nixpkgs
└── channels_root -> /nix/var/nix/profiles/per-user/root/channels
    ├── ...
    └── nixos -> /nix/store/53b.../nixos

(channels contains the user-specific channels while channels_root contains the channels that root subscribed to and are available to all users)

So if you decided to use the user1's subscription to nixpkgs then you would run:

NIX_PATH="nixpkgs=/home/user1/.nix-defexpr/channels/nixpkgs" nix-env -f default.nix -i

  • I understood everything until the last line. However what I need to do is to set nixpkgs-unstable as the default channel for my user. I will not be using a default.nix file. How would I correct the behaviour then? – dmvianna Feb 17 '18 at 20:32
  • 1
    <nixpkgs> is not some magic bound to a "default channel" - it just instructs nix to look into the NIX_PATH linux environment variable and look for an assignment of the form "nixpkgs=..." and use the right side of the assignment as the value of <nixpkgs>. You can prefix any command in linux with an assignment like I showed above and it will set the environment variable just for that one command invocation. – fghibellini Feb 17 '18 at 20:39
  • 1
  • 1
    I believe the config gets passed the package set of the 'nixos' channel root is subscribed to, but I cannot find any documentation regarding it. – fghibellini Feb 23 '18 at 21:22
  • 1
    another example of using fixed channels with a good explanation garbas.si/2015/reproducible-development-environments.html – fghibellini Feb 25 '18 at 13:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.