Install nix on arch

Hi! I’m trying to get started with nix for the first time. I installed nix on an existing arch linux installation using sudo pacman -S nix. I’m then following these instructions:
https://wiki.archlinux.org/title/Nix#Installation
and have enabled the daemon, added my user to the nix-users group, added a channel and updated it.

But the example with nix-env does not work. Ie nix-env -iA '<nixpkgs>.hello' gives error: attribute '<nixpkgs>' in selection path '<nixpkgs>.hello' not found. I suspect this is because I have no NIX_PATH env variable.

For example if I do nix-instantiate --eval -E '<nixpkgs>' I get an error again, however (NIX_PATH=/home/axel/.nix-defexpr/channels/stable/nixpkgs nix-instantiate --eval -E '<nixpkgs>') does work.

I see mentions of sourcing nix.sh online but I have no such file. Indeed the arch package removes this file:

and the mentioned bug report states that only nix-daemon.sh should be sourced. But that does not have any NIX_PATH in it. Where is this supposed to come from?

Not sure this is related but my ~/.nix-profile is a symlink to a non-existent /home/axel/.local/state/nix/profiles/profile.

Thanks in advance for any help!

Hey, welcome to NixOS discourse!

Is there anything that would prevent you from trying the other installation methods? I think the Determinate Systems installer is easier to use and easier to uninstall, in case you don’t like the experience. (Which I hope will not be necessary of course) :slight_smile:

Thanks for your reply!

No not really, the “native” just look the simplest, ie “just install nix with pacman” haha. But maybe that’s a red herring :slight_smile:

If you don’t have NIX_PATH set there is no chance that something containing <nixpkgs> will work:

This is how that variables is set on NixOS:

❯ echo $NIX_PATH
nixpkgs=flake:nixpkgs:/nix/var/nix/profiles/per-user/root/channels

But even on arch it could work, or maybe you should replace root with your user? (just check the content of /nix/var/nix/profiles/per-user/ folder)

Drop the <nixpkgs> part here.