nix.dev
nix.dev copied to clipboard
`nix-shell -p` does not work out of the box on Void Linux
Following the guide I get this error:
nix-shell -p hello
11/03/2021 | 05:06:35 PM jgart: error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:13
Should there be a getting set up section? Author forgot to mention the above issue.
How did you install Nix?
How did you install Nix?
I installed it with xbps:
https://github.com/void-linux/void-packages/blob/e945e199d6933dc757824cde2f1a0c4664cefe0d/srcpkgs/nix/template
It seems that the installation doesn't install channels by default, what is expected with the official Nix installation.
It seems that the installation doesn't install channels by default, what is expected with the official Nix installation.
@domenkozar Do you happen to know where that might be added here?:
https://github.com/void-linux/void-packages/tree/e945e199d6933dc757824cde2f1a0c4664cefe0d/srcpkgs/nix
Is that a new thing? In my history (on debian) I have
sudo apt install nix
man nix-channel
nix-channel --add https://nixos.org/channels/nixpkgs-unstable
one after the other, and iirc it was because their quickstart/tutorial/whatever said. Here it is - https://nixos.org/manual/nix/stable/package-management/basic-package-mgmt.html
That being said, if one installs nix without a package manager, following https://nixos.org/manual/nix/stable/quick-start.html, their installer subscribes to the unstable channel unless told otherwise.
Imho there should be a message explaining the situation (something like "the package list is empty, choose a channel running eg nix-channel --add https://nixos.org/channels/nixpkgs-unstable"); the place to put it in in post_install, in the file srcpkgs/nix/template.
Finally (and I'm really talking out of my a$$ here) I believe part of the reason is that a channel is a per-user setting - if you have say a family computer, it should be possible that say you follow a channel and your brother a different one, while xbps-install installs globally; please correct me if needed.
I think it would be pretty convenient to not have to configure anything "out of the box".
That would be an awesome experience.
A message letting the user know what channel they are currently subscribed to by default would be nice.
Void is strongly against starting services as part of xbps-install, and without nix-daemon running things like etc nix-channel --update will fail; I tried in a vm, installing nix and adding the channel as root (like the installer would) leads to nix-channel --list showing the added channel for root and nothing for a regular user; nix-channel --update fails even for root complaining that nix-daemon is not running, so your only chance is to add a message to post_install in srcpkgs/nix/template (or install from nixos.org without using xbps).
Does Void allow a way to tell the user how to start using a service? Then the setup could be documented there.
There's a file, $pkgname/template, which is just a shell script specifying dependencies etc; optionally you can have a function called post_install where you can do whatever, eg qemu warns you to modprobe the modules needed for kvm, ssh warns you about a recent incompatible change etc - adding a message warning that to use nix you need to start nix-daemon and add a channel etc would probably be ok (or link to nix-channel(1) which has an "EXAMPLES" section).
FWIW the arch wiki also says that after installation you should...
Configure a default Nix channel and update it:
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ nix-channel --update
$ nix-env -u
That's 3/3 so far, so I guess in your guide you could say something along the lines of "if you installed nix using your distribution's pkg mgr, you may need to run the following three commands (as yourself, not as root) and make sure that the nix daemon is running".
Sounds good - would you like to make a PR?