Automated multi-user nix installation?

I’m trying to automate the multi-user nix installation on servers using Ansible. I’m struggling because of

  • the official installation script not supporting being run as root; and
  • it not being obvious how to run the script in a non-interactive way.

I’m aware Ansible roles already exist but I’ve not found anything up-to-date that supports a multi-user nix installation. I also can’t find clear installation steps that I could write in Ansible for a multi-user installation run as root. Does anybody know how I can proceed? I find it ironic that a tool so fantastic for managing software installations can be so tricky to install itself!

I have one for work that I could scrub a bit to remove stuff related to our usage but you’ll need to tailor it to your needs.

Its fully automatic and automatically cleans up old installs

1 Like
1 Like

@Growpotkin, this sounds really interesting, If you can share I’d really appreciate it.

So if the following code was removed from the installer and the installer ran as root, what would break?

     if [ "$EUID" -eq 0 ]; then 
         failure <<EOF 
 Please do not run this script with root privileges. I will call sudo 
 when I need to. 

Is the problem simply that when run as root, commands should not be prefixed with sudo since sudo might not be available? Is that all that would need fixing?

This Ansible role does the job: