povman
1
I have multiple channels:
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-19.03-darwin
nixpkgs-new https://nixos.org/channels/nixpkgs-19.09-darwin
How would I select nixpkgs-new
when opening a nix-shell?
(I know you can do nix-shell -I nixpkgs=channel:nixpkgs-19.09-darwin -p ...
- really wondering how to select a local channel).
2 Likes
I only have one channel but I expect you can write something like nix-shell -p hello '<nixpkgs>'
That said, if you’re trying to create a shell with the given set of packages available, nix run
is the better tool for that.
2 Likes
palo
3
I’m not using channels, but I use this command every now and than
nix-shell -I nixpkgs=/var/src/nixpkgs-unstable -p git
when I want to install something from the unstable branch.
For that I have to clone the repository in /var/src/nixpkgs-unstable
.
1 Like
The channels are located under /nix/var/nix/profiles/per-user/$USER/channels
. So for example if the user was root
:
nix-shell -I nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs-new
or this works too:
NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs-new nix-shell
3 Likes
I’m having trouble getting this to work actually. I have the nixpkgs-unstable channel:
$ nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/release-20.09.tar.gz
nixpkgs-unstable https://nixos.org/channels/nixpkgs-unstable
But when I go to use it:
$ nix-shell -p julia_15 '<nixpkgs-unstable>'
error: undefined variable 'julia_15' at (string):1:94
(use '--show-trace' to show detailed location information)
even though julia_15 is in the unstable channel. Am I doing something wrong here?
I’m on NixOS 20.09.1632.a6a3a368dda (Nightingale).
Oh interesting, I had no idea that channels were on the way out!
You can also pass nix code to the nix-shell
-p
flag:
$ nix-shell -p '(import <unstable> {}).hello'
6 Likes