Nix: how to correctly install Nix on ArchLinux

Created on 13 Apr 2016  Â·  19Comments  Â·  Source: NixOS/nix

situation:

./configure --prefix=/usr \
              --libexecdir="/usr/lib/$pkgname" \
              --sysconfdir=/etc \
              --enable-gc
make
make install

expected:

  • out of box working Nix (nix-env, nix-channel, etc.) under root account
  • not usable Nix under user accounts

current result:

  • logging in as root first time will initialize Nix for root
  • but running nix-env will print error message:
warning: the group ‘nixbld’ specified in ‘build-users-group’ does not exist
building path(s) ‘/nix/store/n2i7g8pmylm2wbxz2hl1fvyfz3ay7vcp-user-environment’
error: the group ‘nixbld’ specified in ‘build-users-group’ does not exist
  • logging in as regular user will always print messages:
mkdir: cannot create directory ‘/nix/var/nix/profiles/per-user/k2s’: Permission denied
stat: cannot stat '/nix/var/nix/profiles/per-user/k2s': No such file or directory
Nix: WARNING: bad ownership on /nix/var/nix/profiles/per-user/k2s, should be 1000
mkdir: cannot create directory ‘/nix/var/nix/gcroots/per-user/k2s’: Permission denied
stat: cannot stat '/nix/var/nix/gcroots/per-user/k2s': No such file or directory
Nix: WARNING: bad ownership on /nix/var/nix/gcroots/per-user/k2s, should be 1000
/usr/lib/prezto/modules/fasd/init.zsh:32: permission denied: /usr/lib/prezto/modules/fasd/cache.zsh

I would like to fix Nix installation on ArchLinux, but need to understand:

  1. should latest version of Nix be installed always with multiuser in mind ?
  2. build-users-group=nixbld seams to be now default setting (had to be added manually before), should it be somehow cleared in /etc/nix/nix.conf or should it be always created in OS package ?
  3. Nix install will not chmod 1777 /nix/var/nix/{profiles,gcroots}/per-user. Should ArchLinux package always apply this or should nix-profile.sh.in be changed to handle such situation (handle non-multiuser setup) ?
installer

Most helpful comment

@Cutuchiqueno I think this is a pretty good writeup https://gist.github.com/expipiplus1/e571ce88c608a1e83547c918591b149f.

All 19 comments

Looks like nix is assuming things about nixbld when running as root?

Not sure how to fix atm…

  1. reading edolstra reaction tells me, that Nix installation should support booth, single and multi, user setup
  2. If Nix relays now on nixbld group, I will create it in ArchLinux package. But would like to get some "authoritative" answer from Nix development team
  3. same issue was discovered by test so I would propose that @wmertens script should test if /nix/var/nix/{profiles,gcroots}/per-user was made writable

I think it would be a good idea to provide the nixbld group. The script doesn't need to test if that dir is writeable, in normal operation you simply get an error message, nothing more.

Any progress here, please?

cc @edolstra, this one is very unpleasant.

Yeah not too sure if I'm encountering the same problem but:

 ✘ chris@archamd  ~  nix-env -q
error: creating directory ‘/nix’: Permission denied
 ✘ chris@archamd  ~  sudo nix-env -q
warning: the group ‘nixbld’ specified in ‘build-users-group’ does not exist
 chris@archamd î‚° ~ î‚° group
 ✘ chris@archamd  ~  sudo nix-env -i                                                                                                                                                         
warning: the group ‘nixbld’ specified in ‘build-users-group’ does not exist
error: getting information about ‘/root/.nix-defexpr’: No such file or directory
 ✘ chris@archamd  ~  sudo nix-env -i vim
warning: the group ‘nixbld’ specified in ‘build-users-group’ does not exist
error: getting information about ‘/root/.nix-defexpr’: No such file or directory

I'm also having the same issues as @chrissound, unable to use nix on Archlinux because of this.

Just tried this again and I'm still having issues:

nix-env -q        
error: Nix database directory ‘/nix/var/nix/db’ is not writable: Permission denied
sudo nix-env -q
warning: the group ‘nixbld’ specified in ‘build-users-group’ does not exist

I've been using nix on arch linux for a long time. I use sysusers.d and tmpfiles.d to intialize stuff + the bootstrap tarball, works really well here ...
EDIT: that is to say, I don't know that there's really an issue with arch linux per se

@joachifm what are sysusers.d and tmpfiles.d? I don't see any mention of those on http://nixos.org/nix/manual/ could you point me to any resources?

@chrissound sorry, I was referring to systemd-{sysusers,tmpfiles}, a convenient method of initializing the requisite users and directory structure for nix.

@joachifm can you elaborate on the exact steps you took to get nix working with using your approach?

@Cutuchiqueno I think this is a pretty good writeup https://gist.github.com/expipiplus1/e571ce88c608a1e83547c918591b149f.

Just to confirm I got it working with the link provided. Thank you @joachifm

The AUR package (https://aur.archlinux.org/packages/nix/) would need to be updated to include those instructions in the PKGBUILD file. I had to mkdir /nix chown chris:chris /nix.

@expipiplus1's instructions work for me too.

Thanks to the pointer by kyrias, I managed to make nix work in ArchLinux with:

sudo pacman -S rsync
bash <(curl https://nixos.org/nix/install) --daemon
# After finishing the installer there's this message:
# Before Nix will work in your existing shells, you'll need to close
# them and open them again. Other than that, you should be ready to go.

# Try it! Open a new terminal, and type:

#  $ nix-shell -p nix-info --run "nix-info -m"

# But the nix commands were not added to my PATH, did a:
source /etc/profile.d/nix.sh
# and all working good now, added that to my .bashrc as well

Fresh new user here, I did the same as @steve-chavez (https://github.com/NixOS/nix/issues/879#issuecomment-410904367), it worked well!

I guess this issue can be closed?

Want to second @bew and @steve-chavez - following the steps in #879r410904367 (on a fresh Arch install) worked perfectly!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luc65r picture luc65r  Â·  3Comments

ericsagnes picture ericsagnes  Â·  4Comments

daraul picture daraul  Â·  3Comments

drewm1980 picture drewm1980  Â·  3Comments

LisannaAtHome picture LisannaAtHome  Â·  3Comments