Skip to content

Instantly share code, notes, and snippets.

@shirakaba
Last active February 3, 2023 19:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirakaba/984bb11e7a5e82edcf83d66cbfd6d9fe to your computer and use it in GitHub Desktop.
Save shirakaba/984bb11e7a5e82edcf83d66cbfd6d9fe to your computer and use it in GitHub Desktop.
Setting up Nix and Home Manager on a new M1 Mac (circa Dec 2021)

Background

I have a brand new M1 MacBook Pro. I have a long list of complaints with homebrew, so I want to try Nix as my package manager instead, along with Home Manager to control my setup on a per-user basis. Once I've set this all up, theoretically, I should be able to reuse the same configuration on any other Macs I own.

What is Nix?

A reproducible, declarative package manager.

More info:

What is Home Manager?

Home Manager allows you to manage packages, preferences, and dotfiles differently between users. So instead of setting up a single Nix configuration that applies to your whole computer, you can have per-user configurations. You could actually set this up through Nix alone, but you'd simply be reinventing Home Manager.

More info:

Walkthrough

1. Installing Nix

I did a multi-user install of Nix because indeed I have multiple user accounts on my Mac.

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
  • --daemon: necessary for multi-user installs.
  • --darwin-use-unencrypted-nix-store-volume: I only included this flag because I was following some older instructions; nowadays it just no-ops. Relates to FileVault. More info here.
Terminal output
jamie@Jamie-M1-MBP ~ % sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  4024  100  4024    0     0  12625      0 --:--:-- --:--:-- --:--:-- 12625
downloading Nix 2.4 binary tarball for aarch64-darwin from 'https://releases.nixos.org/nix/nix-2.4/nix-2.4-aarch64-darwin.tar.xz' to '/var/folders/0m/nf10bfxx6rgft8tn29fznymc0000gn/T/nix-binary-tarball-unpack.XXXXXXXXXX.VaxnLPfN'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 18.3M  100 18.3M    0     0  12.5M      0  0:00:01  0:00:01 --:--:-- 12.6M
Warning: the flag --darwin-use-unencrypted-nix-store-volume
         is no longer needed and will be removed in the future.

Switching to the Multi-user Installer
Welcome to the Multi-User Nix Installation

This installation tool will set up your computer with the Nix package
manager. This will happen in a few stages:

1. Make sure your computer doesn't already have Nix. If it does, I
   will show you instructions on how to clean up your old install.

2. Show you what we are going to install and where. Then we will ask
   if you are ready to continue.

3. Create the system users and groups that the Nix daemon uses to run
   builds.

4. Perform the basic installation of the Nix files daemon.

5. Configure your shell to import special Nix Profile files, so you
   can use Nix.

6. Start the Nix daemon.

Would you like to see a more detailed list of what we will do?
[y/n] y


We will:

 - make sure your computer doesn't already have Nix files
   (if it does, I will tell you how to clean them up.)
 - create local users (see the list above for the users we'll make)
 - create a local group (nixbld)
 - install Nix in to /nix
 - create a configuration file in /etc/nix
 - set up the "default profile" by creating some Nix-related files in
   /var/root
 - back up /etc/bashrc to /etc/bashrc.backup-before-nix
 - update /etc/bashrc to include some Nix configuration
 - back up /etc/zshrc to /etc/zshrc.backup-before-nix
 - update /etc/zshrc to include some Nix configuration
 - create a Nix volume and a LaunchDaemon to mount it
 - create a LaunchDaemon (at /Library/LaunchDaemons/org.nixos.nix-daemon.plist) for nix-daemon

Ready to continue?
[y/n] y


---- let's talk about sudo -----------------------------------------------------
This script is going to call sudo a lot. Every time we do, it'll
output exactly what it'll do, and why.

Just like this:

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo echo

to demonstrate how our sudo prompts look


This might look scary, but everything can be undone by running just a
few commands. We used to ask you to confirm each time sudo ran, but it
was too many times. Instead, I'll just ask you this one time:

Can we use sudo?
[y/n] y

Yay! Thanks! Let's get going!

~~> Fixing any leftover Nix volume state
Before I try to install, I'll check for any existing Nix volume config
and ask for your permission to remove it (so that the installer can
start fresh). I'll also ask for permission to fix any issues I spot.

---- Nix config report ---------------------------------------------------------
        Temp Dir:	/var/folders/0m/nf10bfxx6rgft8tn29fznymc0000gn/T/tmp.cM3wyxph4I
        Nix Root:	/nix
     Build Users:	32
  Build Group ID:	30000
Build Group Name:	nixbld

build users:
    Username:	UID
     _nixbld1:	301
     _nixbld2:	302
     _nixbld3:	303
     _nixbld4:	304
     _nixbld5:	305
     _nixbld6:	306
     _nixbld7:	307
     _nixbld8:	308
     _nixbld9:	309
     _nixbld10:	310
     _nixbld11:	311
     _nixbld12:	312
     _nixbld13:	313
     _nixbld14:	314
     _nixbld15:	315
     _nixbld16:	316
     _nixbld17:	317
     _nixbld18:	318
     _nixbld19:	319
     _nixbld20:	320
     _nixbld21:	321
     _nixbld22:	322
     _nixbld23:	323
     _nixbld24:	324
     _nixbld25:	325
     _nixbld26:	326
     _nixbld27:	327
     _nixbld28:	328
     _nixbld29:	329
     _nixbld30:	330
     _nixbld31:	331
     _nixbld32:	332

Ready to continue?
[y/n] y


---- Preparing a Nix volume ----------------------------------------------------
    Nix traditionally stores its data in the root directory /nix, but
    macOS now (starting in 10.15 Catalina) has a read-only root directory.
    To support Nix, I will create a volume and configure macOS to mount it
    at /nix.

~~> Configuring /etc/synthetic.conf to make a mount-point at /nix

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/ex /etc/synthetic.conf

to add Nix to /etc/synthetic.conf

Password:

~~> Creating a Nix volume

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/diskutil apfs addVolume disk3 APFS Nix Store -nomount

to create a new APFS volume 'Nix Store' on disk3


~~> Configuring /etc/fstab to specify volume mount options

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/vifs

to add nix to fstab

Volume Nix Store on Nix Store mounted

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/security -i

to add your Nix volume's password to Keychain


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/diskutil apfs encryptVolume Nix Store -user disk -stdinpassphrase

to encrypt your Nix volume

Encrypting with the new "Disk" crypto user on disk3s7
The new "Disk" user will be the only one who has initial access to disk3s7
The new APFS crypto user UUID will be 36E57FC6-BE0F-4CAB-ABD5-605BAF34BD34
Encryption has likely completed due to AES hardware; see "diskutil apfs list"
Volume Nix Store on disk3s7 force-unmounted

~~> Configuring LaunchDaemon to mount 'Nix Store'

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/ex /Library/LaunchDaemons/org.nixos.darwin-store.plist

to install the Nix volume mounter


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo launchctl bootstrap system /Library/LaunchDaemons/org.nixos.darwin-store.plist

to launch the Nix volume mounter


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo launchctl kickstart -k system/org.nixos.darwin-store

to launch the Nix volume mounter


~~> Setting up the build group nixbld

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o create -r Nix build group for nix-daemon -i 30000 nixbld

Create the Nix build group, nixbld

            Created:	Yes

~~> Setting up the build user _nixbld1

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld1 UniqueID 301

Creating the Nix build user (#1), _nixbld1

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld1 IsHidden 1

in order to make _nixbld1 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld1 NFSHomeDirectory /var/empty

in order to give _nixbld1 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 1

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld1 UserShell /sbin/nologin

in order to give _nixbld1 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld1 nixbld

Add _nixbld1 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld1 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld2

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld2 UniqueID 302

Creating the Nix build user (#2), _nixbld2

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld2 IsHidden 1

in order to make _nixbld2 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld2 NFSHomeDirectory /var/empty

in order to give _nixbld2 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 2

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld2 UserShell /sbin/nologin

in order to give _nixbld2 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld2 nixbld

Add _nixbld2 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld2 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld3

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld3 UniqueID 303

Creating the Nix build user (#3), _nixbld3

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld3 IsHidden 1

in order to make _nixbld3 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld3 NFSHomeDirectory /var/empty

in order to give _nixbld3 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 3

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld3 UserShell /sbin/nologin

in order to give _nixbld3 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld3 nixbld

Add _nixbld3 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld3 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld4

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld4 UniqueID 304

Creating the Nix build user (#4), _nixbld4

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld4 IsHidden 1

in order to make _nixbld4 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld4 NFSHomeDirectory /var/empty

in order to give _nixbld4 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 4

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld4 UserShell /sbin/nologin

in order to give _nixbld4 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld4 nixbld

Add _nixbld4 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld4 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld5

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld5 UniqueID 305

Creating the Nix build user (#5), _nixbld5

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld5 IsHidden 1

in order to make _nixbld5 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld5 NFSHomeDirectory /var/empty

in order to give _nixbld5 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 5

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld5 UserShell /sbin/nologin

in order to give _nixbld5 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld5 nixbld

Add _nixbld5 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld5 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld6

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld6 UniqueID 306

Creating the Nix build user (#6), _nixbld6

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld6 IsHidden 1

in order to make _nixbld6 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld6 NFSHomeDirectory /var/empty

in order to give _nixbld6 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 6

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld6 UserShell /sbin/nologin

in order to give _nixbld6 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld6 nixbld

Add _nixbld6 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld6 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld7

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld7 UniqueID 307

Creating the Nix build user (#7), _nixbld7

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld7 IsHidden 1

in order to make _nixbld7 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld7 NFSHomeDirectory /var/empty

in order to give _nixbld7 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 7

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld7 UserShell /sbin/nologin

in order to give _nixbld7 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld7 nixbld

Add _nixbld7 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld7 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld8

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld8 UniqueID 308

Creating the Nix build user (#8), _nixbld8

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld8 IsHidden 1

in order to make _nixbld8 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld8 NFSHomeDirectory /var/empty

in order to give _nixbld8 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 8

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld8 UserShell /sbin/nologin

in order to give _nixbld8 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld8 nixbld

Add _nixbld8 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld8 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld9

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld9 UniqueID 309

Creating the Nix build user (#9), _nixbld9

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld9 IsHidden 1

in order to make _nixbld9 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld9 NFSHomeDirectory /var/empty

in order to give _nixbld9 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 9

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld9 UserShell /sbin/nologin

in order to give _nixbld9 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld9 nixbld

Add _nixbld9 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld9 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld10

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld10 UniqueID 310

Creating the Nix build user (#10), _nixbld10

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld10 IsHidden 1

in order to make _nixbld10 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld10 NFSHomeDirectory /var/empty

in order to give _nixbld10 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 10

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld10 UserShell /sbin/nologin

in order to give _nixbld10 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld10 nixbld

Add _nixbld10 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld10 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld11

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld11 UniqueID 311

Creating the Nix build user (#11), _nixbld11

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld11 IsHidden 1

in order to make _nixbld11 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld11 NFSHomeDirectory /var/empty

in order to give _nixbld11 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 11

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld11 UserShell /sbin/nologin

in order to give _nixbld11 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld11 nixbld

Add _nixbld11 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld11 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld12

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld12 UniqueID 312

Creating the Nix build user (#12), _nixbld12

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld12 IsHidden 1

in order to make _nixbld12 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld12 NFSHomeDirectory /var/empty

in order to give _nixbld12 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 12

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld12 UserShell /sbin/nologin

in order to give _nixbld12 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld12 nixbld

Add _nixbld12 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld12 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld13

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld13 UniqueID 313

Creating the Nix build user (#13), _nixbld13

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld13 IsHidden 1

in order to make _nixbld13 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld13 NFSHomeDirectory /var/empty

in order to give _nixbld13 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 13

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld13 UserShell /sbin/nologin

in order to give _nixbld13 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld13 nixbld

Add _nixbld13 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld13 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld14

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld14 UniqueID 314

Creating the Nix build user (#14), _nixbld14

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld14 IsHidden 1

in order to make _nixbld14 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld14 NFSHomeDirectory /var/empty

in order to give _nixbld14 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 14

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld14 UserShell /sbin/nologin

in order to give _nixbld14 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld14 nixbld

Add _nixbld14 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld14 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld15

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld15 UniqueID 315

Creating the Nix build user (#15), _nixbld15

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld15 IsHidden 1

in order to make _nixbld15 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld15 NFSHomeDirectory /var/empty

in order to give _nixbld15 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 15

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld15 UserShell /sbin/nologin

in order to give _nixbld15 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld15 nixbld

Add _nixbld15 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld15 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld16

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld16 UniqueID 316

Creating the Nix build user (#16), _nixbld16

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld16 IsHidden 1

in order to make _nixbld16 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld16 NFSHomeDirectory /var/empty

in order to give _nixbld16 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 16

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld16 UserShell /sbin/nologin

in order to give _nixbld16 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld16 nixbld

Add _nixbld16 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld16 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld17

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld17 UniqueID 317

Creating the Nix build user (#17), _nixbld17

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld17 IsHidden 1

in order to make _nixbld17 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld17 NFSHomeDirectory /var/empty

in order to give _nixbld17 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 17

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld17 UserShell /sbin/nologin

in order to give _nixbld17 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld17 nixbld

Add _nixbld17 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld17 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld18

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld18 UniqueID 318

Creating the Nix build user (#18), _nixbld18

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld18 IsHidden 1

in order to make _nixbld18 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld18 NFSHomeDirectory /var/empty

in order to give _nixbld18 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 18

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld18 UserShell /sbin/nologin

in order to give _nixbld18 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld18 nixbld

Add _nixbld18 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld18 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld19

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld19 UniqueID 319

Creating the Nix build user (#19), _nixbld19

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld19 IsHidden 1

in order to make _nixbld19 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld19 NFSHomeDirectory /var/empty

in order to give _nixbld19 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 19

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld19 UserShell /sbin/nologin

in order to give _nixbld19 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld19 nixbld

Add _nixbld19 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld19 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld20

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld20 UniqueID 320

Creating the Nix build user (#20), _nixbld20

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld20 IsHidden 1

in order to make _nixbld20 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld20 NFSHomeDirectory /var/empty

in order to give _nixbld20 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 20

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld20 UserShell /sbin/nologin

in order to give _nixbld20 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld20 nixbld

Add _nixbld20 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld20 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld21

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld21 UniqueID 321

Creating the Nix build user (#21), _nixbld21

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld21 IsHidden 1

in order to make _nixbld21 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld21 NFSHomeDirectory /var/empty

in order to give _nixbld21 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 21

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld21 UserShell /sbin/nologin

in order to give _nixbld21 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld21 nixbld

Add _nixbld21 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld21 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld22

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld22 UniqueID 322

Creating the Nix build user (#22), _nixbld22

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld22 IsHidden 1

in order to make _nixbld22 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld22 NFSHomeDirectory /var/empty

in order to give _nixbld22 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 22

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld22 UserShell /sbin/nologin

in order to give _nixbld22 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld22 nixbld

Add _nixbld22 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld22 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld23

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld23 UniqueID 323

Creating the Nix build user (#23), _nixbld23

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld23 IsHidden 1

in order to make _nixbld23 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld23 NFSHomeDirectory /var/empty

in order to give _nixbld23 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 23

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld23 UserShell /sbin/nologin

in order to give _nixbld23 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld23 nixbld

Add _nixbld23 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld23 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld24

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld24 UniqueID 324

Creating the Nix build user (#24), _nixbld24

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld24 IsHidden 1

in order to make _nixbld24 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld24 NFSHomeDirectory /var/empty

in order to give _nixbld24 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 24

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld24 UserShell /sbin/nologin

in order to give _nixbld24 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld24 nixbld

Add _nixbld24 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld24 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld25

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld25 UniqueID 325

Creating the Nix build user (#25), _nixbld25

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld25 IsHidden 1

in order to make _nixbld25 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld25 NFSHomeDirectory /var/empty

in order to give _nixbld25 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 25

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld25 UserShell /sbin/nologin

in order to give _nixbld25 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld25 nixbld

Add _nixbld25 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld25 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld26

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld26 UniqueID 326

Creating the Nix build user (#26), _nixbld26

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld26 IsHidden 1

in order to make _nixbld26 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld26 NFSHomeDirectory /var/empty

in order to give _nixbld26 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 26

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld26 UserShell /sbin/nologin

in order to give _nixbld26 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld26 nixbld

Add _nixbld26 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld26 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld27

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld27 UniqueID 327

Creating the Nix build user (#27), _nixbld27

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld27 IsHidden 1

in order to make _nixbld27 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld27 NFSHomeDirectory /var/empty

in order to give _nixbld27 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 27

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld27 UserShell /sbin/nologin

in order to give _nixbld27 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld27 nixbld

Add _nixbld27 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld27 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld28

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld28 UniqueID 328

Creating the Nix build user (#28), _nixbld28

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld28 IsHidden 1

in order to make _nixbld28 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld28 NFSHomeDirectory /var/empty

in order to give _nixbld28 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 28

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld28 UserShell /sbin/nologin

in order to give _nixbld28 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld28 nixbld

Add _nixbld28 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld28 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld29

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld29 UniqueID 329

Creating the Nix build user (#29), _nixbld29

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld29 IsHidden 1

in order to make _nixbld29 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld29 NFSHomeDirectory /var/empty

in order to give _nixbld29 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 29

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld29 UserShell /sbin/nologin

in order to give _nixbld29 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld29 nixbld

Add _nixbld29 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld29 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld30

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld30 UniqueID 330

Creating the Nix build user (#30), _nixbld30

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld30 IsHidden 1

in order to make _nixbld30 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld30 NFSHomeDirectory /var/empty

in order to give _nixbld30 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 30

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld30 UserShell /sbin/nologin

in order to give _nixbld30 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld30 nixbld

Add _nixbld30 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld30 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld31

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld31 UniqueID 331

Creating the Nix build user (#31), _nixbld31

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld31 IsHidden 1

in order to make _nixbld31 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld31 NFSHomeDirectory /var/empty

in order to give _nixbld31 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 31

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld31 UserShell /sbin/nologin

in order to give _nixbld31 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld31 nixbld

Add _nixbld31 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld31 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the build user _nixbld32

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld32 UniqueID 332

Creating the Nix build user (#32), _nixbld32

           Created:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld32 IsHidden 1

in order to make _nixbld32 a hidden user

            Hidden:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld32 NFSHomeDirectory /var/empty

in order to give _nixbld32 a safe home directory

    Home Directory:	/var/empty
              Note:	Nix build user 32

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld32 UserShell /sbin/nologin

in order to give _nixbld32 a safe home directory

   Logins Disabled:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/dseditgroup -o edit -t user -a _nixbld32 nixbld

Add _nixbld32 to the nixbld group

  Member of nixbld:	Yes

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . -create /Users/_nixbld32 PrimaryGroupID 30000

to let the nix daemon use this user for builds (this might seem redundant, but there are two concepts of group membership)

    PrimaryGroupID:	30000

~~> Setting up the basic directory structure

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/sbin/chown -R root:nixbld /nix

to take root ownership of existing Nix store files

chown: /nix/.Trashes: Operation not permitted
chown: /nix/.Trashes: Operation not permitted

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo install -dv -m 0755 /nix /nix/var /nix/var/log /nix/var/log/nix /nix/var/log/nix/drvs /nix/var/nix /nix/var/nix/db /nix/var/nix/gcroots /nix/var/nix/profiles /nix/var/nix/temproots /nix/var/nix/userpool /nix/var/nix/gcroots/per-user /nix/var/nix/profiles/per-user

to make the basic directory structure of Nix (part 1)

install: mkdir /nix/var
install: mkdir /nix/var/log
install: mkdir /nix/var/log/nix
install: mkdir /nix/var/log/nix/drvs
install: mkdir /nix/var/nix
install: mkdir /nix/var/nix/db
install: mkdir /nix/var/nix/gcroots
install: mkdir /nix/var/nix/profiles
install: mkdir /nix/var/nix/temproots
install: mkdir /nix/var/nix/userpool
install: mkdir /nix/var/nix/gcroots/per-user
install: mkdir /nix/var/nix/profiles/per-user

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo install -dv -g nixbld -m 1775 /nix/store

to make the basic directory structure of Nix (part 2)

install: mkdir /nix/store

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo install -dv -m 0555 /etc/nix

to place the default nix daemon configuration (part 1)

install: mkdir /etc/nix

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo install -m 0664 /var/folders/0m/nf10bfxx6rgft8tn29fznymc0000gn/T/tmp.cM3wyxph4I/.nix-channels /var/root/.nix-channels

to set up the default system channel (part 1)


~~> Installing Nix

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo cp -RLp ./store/0jqnrzcrh5xxrjxiiisgwcmq62p07s68-apple-lib-libDER ./store/17m4bcp3y2y99g1bka0wfvp0x26l744g-aws-c-io-0.9.1 ./store/2cl9n67fjnczrbaqlww4ipp2z3mnw5dz-libkrb5-1.18 ./store/3pzpaacii5gb60n2x9f9hs93bnakyqgr-sqlite-3.35.5 ./store/775cc9g4k78ay84w4iy15z0q426yny1n-libcxx-11.1.0 ./store/8imb44frl4jrgjpq89hcph15s7lffhd0-bash-4.4-p23 ./store/92wka994gxzb5p5rgdj0a8p1kp9ayv0a-zstd-1.4.9 ./store/9dg39kyqa8zqnivp83h7cczkd21vmyp9-aws-c-cal-0.4.5 ./store/a6745bp7pzbzb7xbigg5jrbp75lanb61-editline-1.17.1 ./store/b3079yijhwkgp23rn3i5x1bm6zbfd3rb-bzip2-1.0.6.0.2 ./store/bn1svfd6w0mjscvndpr08z161i8zycb5-curl-7.76.1 ./store/c7lpgqfw4izdxspdy8s94rd9hwlpw78s-libiconv-50 ./store/f9sqmvn5vc31dy57iyv8rvsdakr281qx-apple-framework-CoreFoundation-11.0.0 ./store/gmvv7m4nmfrv07md98a4hqpwxcl0aa6c-boehm-gc-8.0.4 ./store/gnmpa9am81x0qb0r7447fzn6asfvrnln-libobjc-11.0.0 ./store/gx0g26n0jjxcspz8g9ipq9sgjl7y0d4v-xz-5.2.5 ./store/h6jk3cqh5yqwki20ajf0bb38xcqrlinf-icu4c-69.1 ./store/hbfqs62r0hga2yr4zi5kc7fzhf71bq9n-nix-2.4 ./store/hsbqghjjayl9k55ng276gvi26sn7g137-aws-checksums-0.1.11 ./store/jxxlf9z137d7nfinqmscinv5ma30ckz5-apple-framework-IOKit-11.0.0 ./store/kd0vg2scdiwrnhh8425ixjs7qfsif2s8-openssl-1.1.1l ./store/l6475m8070amp2lkxz8s36sxwykkqbn4-nss-cacert-3.66 ./store/lni8nijamx09clm42pgbl4by1gmaa6mv-aws-sdk-cpp-1.8.121 ./store/mak8qr0sq1v8h2gknkw2xhlp5xvjh6fz-zlib-1.2.11 ./store/mlspxp4w6nday8ggxp30lmx6acd61v7w-libxml2-2.9.12 ./store/mswlivp76jpf68069gcf0ivkc07kf1l3-nghttp2-1.43.0-lib ./store/pssw9x69dxpwmjn84ac8a8xf7irhy2qj-libssh2-1.9.0 ./store/pygjnddvk75kpxvk1ipr9y80wj03jrqa-libarchive-3.5.2-lib ./store/q2v2ikih1f014sazv74skisbj3ar834q-libsodium-1.0.18 ./store/rx5ij82mb3kdhiqr6qk206hmhyzi73gi-aws-c-common-0.5.5 ./store/s6p2agp3gxkjfwmjswjn8gpyv8l2ijxp-apple-framework-Security-11.0.0 ./store/sp33d11b1wqyaijrhyryvgpgz5vnpahk-aws-c-event-stream-0.2.7 ./store/xj7ksmdfhk8r7wykqwnv6qv2bk12px3y-boost-1.69.0 ./store/xms94awpivf7k6gi2xk9qzpdbzv3f3zr-libcxxabi-11.1.0 ./store/yfg8rhph33103x3949w3zy0aapx1jcms-brotli-1.0.9-lib /nix/store/

to copy the basic Nix files to the new store at /nix/store


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo chmod -R ugo-w /nix/store/

to make the new store non-writable at /nix/store

      Alright! We have our first nix at /nix/store/hbfqs62r0hga2yr4zi5kc7fzhf71bq9n-nix-2.4

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /nix/store/hbfqs62r0hga2yr4zi5kc7fzhf71bq9n-nix-2.4/bin/nix-store --load-db

to load data for the first time in to the Nix Database

      Just finished getting the nix database ready.

~~> Setting up shell profiles: /etc/bashrc /etc/profile.d/nix.sh /etc/zshrc /etc/bash.bashrc /etc/zsh/zshrc

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo cp /etc/bashrc /etc/bashrc.backup-before-nix

to back up your current /etc/bashrc to /etc/bashrc.backup-before-nix


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo tee -a /etc/bashrc

extend your /etc/bashrc with nix-daemon settings


# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
  . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo cp /etc/zshrc /etc/zshrc.backup-before-nix

to back up your current /etc/zshrc to /etc/zshrc.backup-before-nix


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo tee -a /etc/zshrc

extend your /etc/zshrc with nix-daemon settings


# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
  . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo touch /etc/bash.bashrc

to create a stub /etc/bash.bashrc which will be updated


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo tee -a /etc/bash.bashrc

extend your /etc/bash.bashrc with nix-daemon settings


# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
  . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix


~~> Setting up the default profile

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo HOME=/var/root /nix/store/hbfqs62r0hga2yr4zi5kc7fzhf71bq9n-nix-2.4/bin/nix-env -i /nix/store/hbfqs62r0hga2yr4zi5kc7fzhf71bq9n-nix-2.4

to install a bootstrapping Nix in to the default profile

installing 'nix-2.4'
building '/nix/store/qxn40f47424172g0s1p9an80w857g4zg-user-environment.drv'...

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo HOME=/var/root /nix/store/hbfqs62r0hga2yr4zi5kc7fzhf71bq9n-nix-2.4/bin/nix-env -i /nix/store/l6475m8070amp2lkxz8s36sxwykkqbn4-nss-cacert-3.66

to install a bootstrapping SSL certificate just for Nix in to the default profile

installing 'nss-cacert-3.66'
building '/nix/store/12v24i1d0j0h73larcd0jhyinkl1jxr2-user-environment.drv'...

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo HOME=/var/root NIX_SSL_CERT_FILE=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt /nix/store/hbfqs62r0hga2yr4zi5kc7fzhf71bq9n-nix-2.4/bin/nix-channel --update nixpkgs

to update the default channel in the default profile

unpacking channels...

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo install -m 0664 /var/folders/0m/nf10bfxx6rgft8tn29fznymc0000gn/T/tmp.cM3wyxph4I/nix.conf /etc/nix/nix.conf

to place the default nix daemon configuration (part 2)


~~> Setting up the nix-daemon LaunchDaemon

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /bin/cp -f /nix/var/nix/profiles/default/Library/LaunchDaemons/org.nixos.nix-daemon.plist /Library/LaunchDaemons/org.nixos.nix-daemon.plist

to set up the nix-daemon as a LaunchDaemon


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist

to load the LaunchDaemon plist for nix-daemon


---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo launchctl kickstart -k system/org.nixos.nix-daemon

to start the nix-daemon

Alright! We're done!
Try it! Open a new terminal, and type:

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

Thank you for using this installer. If you have any feedback or need
help, don't hesitate:

You can open an issue at https://github.com/nixos/nix/issues

Or feel free to contact the team:
 - Matrix: #nix:nixos.org
 - IRC: in #nixos on irc.libera.chat
 - twitter: @nixos_org
 - forum: https://discourse.nixos.org

---- Reminders -----------------------------------------------------------------
[ 1 ]
Nix won't work in active shell sessions until you restart them.

jamie@Jamie-M1-MBP ~ %

2. Installing Home Manager

My steps with reference to Getting started with Home Manager [archive].

2.1 Installing Home Manager itself

# Add the channel for Home Manager
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update

# Populate the NIX_PATH environment variable for both zsh and bash shells.
# It's a workaround for this issue that seems to have been introduced in Nix 2.4,
# in that the installation of Nix no longer seems to populate it for you.
# https://github.com/nix-community/home-manager/issues/2564#issuecomment-994943471
echo 'export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels\n' >> ~/.bash_profile
echo 'export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels\n' >> ~/.zshenv 

# Install Home Manager
nix-shell '<home-manager>' -A install

2.2 (Optional) version-controlling your configuration

The steps in this section are optional. We'll move the configuration folder to another location to version-control it via git, then symlink to it. This will allow us to more safely experiment with different configurations.

# IF YOU HAVEN'T YET AGREED TO THE XCODE LICENSE AGREEMENTS:
# You will need to do so in order to use git on a new macOS device.
#
# We want to use git for the next step, so either run `git status`
# for the first time just to trigger the license agreement, or run
# this explicitly:
sudo xcodebuild -license

# Move your nixpkgs folder to another location to version-control it.
mv ~/.config/nixpkgs ~/nixpkgs-git
cd ~/nixpkgs-git
git init
git add home.nix
git commit -m "Initial commit of Home Manager configuration"

# Symlink to it so that Home Manager can find it as before.
ln -s ~/nixpkgs-git ~/.config/nixpkgs

We'll reload the config just as a sanity-check to make sure our symlinking is all correct. This is what a healthy config load looks like:

home-manager switch
Console output
/nix/store/5z24a5zdimirs79q61h2807419hh3d7x-home-manager-generation
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating copyFonts
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
Activating linkGeneration
Cleaning up orphan links from /Users/jamie
No change so reusing latest profile generation 1
Creating home file links in /Users/jamie
Activating onFilesChange

There are 117 unread and relevant news items.
Read them by running the command "home-manager news".

2.3 Install a package

You can search for packages on https://search.nixos.org/packages?channel=unstable (you'll notice the 'unstable' channel – I'm still unfamiliar with channels, but the guide [archive] I'm referencing uses this). It seems that we should prefix our package name with pkgs. (probably something to do with the import of pkgs at the start of the config file).

Edit your ~/.config/nixpkgs/home.nix file like this:

{ config, pkgs, ... }:

{
  # Home Manager needs a bit of information about you and the
  # paths it should manage.
  home.username = "jamie";
  home.homeDirectory = "/Users/jamie";

+ # https://search.nixos.org/packages?channel=unstable
+ home.packages = [
+   # pkgs is the set of all packages in the default home.nix implementation
+   pkgs.hello
+ ];

Now run this command to reload the configuration, installing the specified package list:

home-manager switch
Console output
these 4 derivations will be built:
  /nix/store/3m4lf0vsqrzya6dbmg1wng6wdy8gqyw5-home-manager-fonts.drv
  /nix/store/pl52dsl2cs4q52128jwlgi76fjngygvy-home-manager-path.drv
  /nix/store/y8wadwf7cc5j0p9sjfivay76b6mziwhk-activation-script.drv
  /nix/store/4bknfkmis0a7nzb5kafnkd82fyrhj0vl-home-manager-generation.drv
this path will be fetched (0.02 MiB download, 0.12 MiB unpacked):
  /nix/store/q8gfl6gpjcyhq9caabhyq9ylp5jphfic-hello-2.10
copying path '/nix/store/q8gfl6gpjcyhq9caabhyq9ylp5jphfic-hello-2.10' from 'https://cache.nixos.org'...
building '/nix/store/3m4lf0vsqrzya6dbmg1wng6wdy8gqyw5-home-manager-fonts.drv'...
created 0 symlinks in user environment
building '/nix/store/pl52dsl2cs4q52128jwlgi76fjngygvy-home-manager-path.drv'...
created 42 symlinks in user environment
building '/nix/store/y8wadwf7cc5j0p9sjfivay76b6mziwhk-activation-script.drv'...
building '/nix/store/4bknfkmis0a7nzb5kafnkd82fyrhj0vl-home-manager-generation.drv'...
/nix/store/yvhhra4v2l869wdiyg7qpdcw61ahbx54-home-manager-generation
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Activating copyFonts
Activating installPackages
replacing old 'home-manager-path'
installing 'home-manager-path'
building '/nix/store/3srrq3s9v0kf3lz676fb09qgrp79xxaf-user-environment.drv'...
Activating linkGeneration
Cleaning up orphan links from /Users/jamie
Creating profile generation 2
Creating home file links in /Users/jamie
Activating onFilesChange

There are 117 unread and relevant news items.
Read them by running the command "home-manager news".

You can now try out the hello command you've just installed:

$ hello
Hello, world!

2.4 (Aside) What is home-manager switch?

I can't say it better than Mattia Gheda in the guide [archive] I've been referencing. See the "What is this home-manager switch business?" section.

I was interested to find that, following installing hello via home-manager switch, one doesn't have to start a new shell session for the hello program to be detected. My zsh shell could find it (if installed) or not (if not installed) in any open shell, always reflecting the currently active home-manager configuration. Similarly, git would always behave as per my programs.git config in home.nix without needing a shell reload.

2.5 Example home.nix

home.nix
{ config, pkgs, ... }:

let
  nixPath = "export NIX_PATH=\${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels";
  homeDirectory = "/Users/jamie";
  nativeScriptCompletion = ''
    if [ -f "${homeDirectory}/.tnsrc" ]; then
      source "${homeDirectory}/.tnsrc"
    fi
  '';
  rustEnv = ". $HOME/.cargo/env";
  reactNativeCleanFunction = ''
    # https://github.com/facebook/react-native/issues/4968#issuecomment-382602642
    function rn-clean() {
      watchman watch-del-all
      rm -rf $TMPDIR/react-*
      rm -rf $TMPDIR/metro-*
      rm -rf $TMPDIR/haste-*
      npm start -- --reset-cache
    }
  '';
  stunnelupFunction = ''
    # Run before using Tunnelblick.
    function stunnelup() {
      /usr/local/bin/stunnel /usr/local/etc/stunnel/stunnel.conf
    }
  '';
  # For now, I've just copied straight from my old bash config.
  # Here's someone's old (possibly unusable, but whatever) shell.nix config to reference in future:
  # https://github.com/uniphil/nix-react-native-base/blob/master/shell.nix
  androidPaths = ''
    ## NativeScript Android environment
    # export ANDROID_HOME=/usr/local/share/android-sdk
    # export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
    # Added by me, based on:
    #  https://stackoverflow.com/questions/56100642/nativescript-cmd-tns-run-android-issue
    #  https://github.com/NativeScript/nativescript-cli/issues/4585#issuecomment-490123143
    # export ANDROID_AVD_HOME=/Users/jamie/.android/avd
    # export ANDROID_AVD_HOME=/usr/local/Caskroom/android-sdk/4333796; export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

    ## React Native Android environment
    export ANDROID_HOME=$HOME/Library/Android/sdk
    export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
    export PATH=$PATH:$ANDROID_HOME/emulator
    export PATH=$PATH:$ANDROID_HOME/tools
    export PATH=$PATH:$ANDROID_HOME/tools/bin
    export PATH=$PATH:$ANDROID_HOME/platform-tools

    ## I downloaded the Android NDK manually to enable Tauri native dev
    export ANDROID_NDK_HOME=/usr/local/share/android-sdk/ndk-bundle
    export NDK_HOME=$ANDROID_NDK_HOME
  '';
  # Export this if ever you want to truncate the terminal prompt, e.g. for screen recordings.
  # https://mattmazur.com/2012/01/27/how-to-change-your-default-terminal-prompt-in-mac-os-x-lion/
  terminalPromptTruncation = "export PS1=\"$ \"";
  # I found that git wasn't using my system SSH, as `UseKeychain yes` in my ~/.ssh/config was not understood.
  # This led to git clone prompting me for my passphrase all the time.
  #   https://apple.stackexchange.com/a/254714
  #   https://github.com/ohmyzsh/ohmyzsh/blob/60b89cd264a5d889573704f5116cefc8e690062c/plugins/ssh-agent/ssh-agent.plugin.zsh#L27
  #   https://www.reddit.com/r/osx/comments/52zn5r/difficulties_with_sshagent_in_macos_sierra/dd4r5fp/
  gitSSH = "export GIT_SSH=/usr/bin/ssh";
  # Workaround for macOS updates overwriting your shell profile.
  #   https://gist.github.com/shirakaba/984bb11e7a5e82edcf83d66cbfd6d9fe#gistcomment-4010892
  nixBootstrap = ''
    if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
      . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
    fi
  '';
  # I figured out these by disabling zsh and bash, then running the Volta install once.
  volta = ''
    export VOLTA_HOME="$HOME/.volta"
    export PATH="$VOLTA_HOME/bin:$PATH"
  '';
  shellEnvCommon = ''
    ${gitSSH}
    ${nixPath}
    ${volta}
    ${nativeScriptCompletion}
    ${reactNativeCleanFunction}
    ${stunnelupFunction}
    ${androidPaths}
    # ${rustEnv}
  '';
in
# https://nix-community.github.io/home-manager/options.html
{
  # Home Manager needs a bit of information about you and the
  # paths it should manage.
  home.username = "jamie";
  home.homeDirectory = homeDirectory;

  # https://search.nixos.org/packages?channel=unstable
  home.packages = [
    pkgs.ffmpeg
    pkgs.jq
    pkgs.tree
    pkgs.youtube-dl
    pkgs.stunnel
    pkgs.multitail
    pkgs.maven
    pkgs.exiftool
    pkgs.watchman
    pkgs.cmake

    ## Used to have, but not sure whether I'll need again:
    # pkgs.qt
    # pkgs.mecab
    # pkgs.sqlite
    # pkgs.wine

    ## Not sure of correct equivalent
    # java8 -> pkgs.jdk8? pkgs.openjdk8-bootstrap?

    ## Not available
    # xcodegen
    # android-sdk
    # android-platform-tools
    # quicklook-json
    # qlmarkdown
    # qlstephen
    # qlstephen
  ];

  home.shellAliases = {
    ll = "ls -la";
    ".." = "cd ..";
    # https://docs.sublimetext.io/guide/getting-started/installation.html#how-to-install-the-portable-version
    subl = "\"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl\"";
    # https://code.visualstudio.com/docs/setup/mac#_alternative-manual-instructions
    code = "\"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code\"";
    ibrew = "arch -x86_64 /usr/local/bin/brew";
    mbrew = "arch -arm64e /opt/homebrew/bin/brew";
  };
  home.sessionVariables = {
    EDITOR = "\\\"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl\\\" -n -w";
  };

  programs.git = {
    enable = true;
    userName = "shirakaba";
    userEmail = "14055146+shirakaba@users.noreply.github.com";
    aliases = {
      co = "checkout";
      br = "branch";
      ci = "commit";
      st = "status";
      # https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
      unstage = "reset HEAD --";
    };
    extraConfig = {
      init.defaultBranch = "main";
    };
  };
  programs.zsh = {
    enable = true;
    # Add bash completion on top of the default compinit.
    completionInit = ''
      autoload -U compinit
      compinit
      autoload -U select-word-style
      select-word-style bash
    '';
    envExtra = ''
      ${shellEnvCommon}
    '';
  };
  programs.bash = {
    enable = true;
    bashrcExtra = ''
      ${shellEnvCommon}
    '';
  };
  programs.java = {
    # Install the Java development kit and set the JAVA_HOME variable.
    enable = true;
  };

  # This value determines the Home Manager release that your
  # configuration is compatible with. This helps avoid breakage
  # when a new Home Manager release introduces backwards
  # incompatible changes.
  #
  # You can update Home Manager without changing this value. See
  # the Home Manager release notes for a list of state version
  # changes in each release.
  home.stateVersion = "22.05";

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}
@Birch-san
Copy link

You may find that macOS updates overwrite your /etc/zshrc (presumably /etc/bash.bashrc is possible too, though this did not happen to me).

As such: you may find that your shells no longer source the Nix environment.

for example, home-manager will no longer be on your PATH (because the directories $HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin will not be on your PATH).

you can fix this by referring to the terminal output in Installing Nix

Ensure that /etc/zshrc contains this patch:

# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
  . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
# End Nix

@shirakaba
Copy link
Author

shirakaba commented Jan 18, 2022

Just ran into the issue mentioned in the above comment following a macOS update (so yes, just add @Birch-san's above code snippet into your /etc/zshrc file if it isn't in there already – probably appending would be best, but prepending works equally well in my case). The rest of my comment below is just for academic interest.


For more documentation of what problem the bootstrapping code solves, here's what situation I found my environment in:

# Using zsh shell
$ which home-manager
home-manager not found
$ which nix
nix not found
$ nix-instantiate '<nixpkgs>' -A hello
zsh: command not found: nix-instantiate
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/jamie/.volta/bin:/Users/jamie/Library/Android/sdk/emulator:/Users/jamie/Library/Android/sdk/tools:/Users/jamie/Library/Android/sdk/tools/bin:/Users/jamie/Library/Android/sdk/platform-tools
$ echo $__ETC_PROFILE_NIX_SOURCED
# Empty line, proving that /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh hasn't been run in the given shell.
# If it had been run, it would instead have printed: 1
cat ~/.zshrc
typeset -U path cdpath fpath manpath



for profile in ${(z)NIX_PROFILES}; do
  fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
done

HELPDIR="/nix/store/mc3qfnwdiwhgzb3i0yz1f42jydyjqddc-zsh-5.8/share/zsh/$ZSH_VERSION/help"









# Oh-My-Zsh/Prezto calls compinit during initialization,
# calling it twice causes slight start up slowdown
# as all $fpath entries will be traversed again.






# Environment variables
. "/Users/jamie/.nix-profile/etc/profile.d/hm-session-vars.sh"


# oh-my-zsh extra settings for plugins

# oh-my-zsh configuration generated by NixOS
plugins=(git sudo)

ZSH_THEME="robbyrussell"
source $ZSH/oh-my-zsh.sh






# History options should be set in .zshrc and after oh-my-zsh sourcing.
# See https://github.com/nix-community/home-manager/issues/177.
HISTSIZE="10000"
SAVEHIST="10000"

HISTFILE="$HOME/.zsh_history"
mkdir -p "$(dirname "$HISTFILE")"

setopt HIST_FCNTL_LOCK
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
unsetopt HIST_EXPIRE_DUPS_FIRST
setopt SHARE_HISTORY
unsetopt EXTENDED_HISTORY




# Aliases
alias ..='cd ..'
alias code='"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"'
alias ibrew='arch -x86_64 /usr/local/bin/brew'
alias ll='ls -la'
alias mbrew='arch -arm64e /opt/homebrew/bin/brew'
alias subl='"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"'

# Global Aliases


# Named Directory Hashes
cat ~/.bashrc
#!/nix/store/7aqi1cxp0q594zl71c8fpkv7zjnzf6rw-bash-5.1-p12/bin/bash
export GIT_SSH=/usr/bin/ssh
export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"

if [ -f "/Users/jamie/.tnsrc" ]; then
  source "/Users/jamie/.tnsrc"
fi

# https://github.com/facebook/react-native/issues/4968#issuecomment-382602642
function rn-clean() {
  watchman watch-del-all
  rm -rf $TMPDIR/react-*
  rm -rf $TMPDIR/metro-*
  rm -rf $TMPDIR/haste-*
  npm start -- --reset-cache
}

# Run before using Tunnelblick.
function stunnelup() {
  /usr/local/bin/stunnel /usr/local/etc/stunnel/stunnel.conf
}

## NativeScript Android environment
# export ANDROID_HOME=/usr/local/share/android-sdk
# export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
# Added by me, based on:
#  https://stackoverflow.com/questions/56100642/nativescript-cmd-tns-run-android-issue
#  https://github.com/NativeScript/nativescript-cli/issues/4585#issuecomment-490123143
# export ANDROID_AVD_HOME=/Users/jamie/.android/avd
# export ANDROID_AVD_HOME=/usr/local/Caskroom/android-sdk/4333796; export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

## React Native Android environment
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

## I downloaded the Android NDK manually to enable Tauri native dev
export ANDROID_NDK_HOME=/usr/local/share/android-sdk/ndk-bundle
export NDK_HOME=$ANDROID_NDK_HOME

# . $HOME/.cargo/env



# Commands that should be applied only for interactive shells.
[[ $- == *i* ]] || return

HISTFILESIZE=100000
HISTSIZE=10000

shopt -s histappend
shopt -s checkwinsize
shopt -s extglob
shopt -s globstar
shopt -s checkjobs

alias ..='cd ..'
alias code='"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"'
alias ibrew='arch -x86_64 /usr/local/bin/brew'
alias ll='ls -la'
alias mbrew='arch -arm64e /opt/homebrew/bin/brew'
alias subl='"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"'

... so it's not that my shell profiles were overwritten, it's just that the daemon wasn't started in the shell.

By adding that bootstrapping code to the start of ~/.zshrc and opening a new zsh shell, things worked again:

# Using zsh shell
$ which home-manager
/Users/jamie/.nix-profile/bin/home-manager
$ which nix
/nix/var/nix/profiles/default/bin/nix
$ nix-instantiate '<nixpkgs>' -A hello
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/8x0hf5vld3jb3zp16vkh1wlhbkr4qik8-hello-2.10.drv
$ echo $PATH
/Users/jamie/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/jamie/.volta/bin:/Users/jamie/Library/Android/sdk/emulator:/Users/jamie/Library/Android/sdk/tools:/Users/jamie/Library/Android/sdk/tools/bin:/Users/jamie/Library/Android/sdk/platform-tools
$ echo $__ETC_PROFILE_NIX_SOURCED
1

So we can either add that bootstrapping code into our home-manager config for the given user, or into the system config for each shell (/etc/zshrc and /etc/bashrc).

I can see in /etc/bashrc that that bootstrapping code is there in the first place (appended to the bottom of the file), so I guess the Nix approach is indeed to edit the system file, so I think I'd best just do that. It probably reduces friction in a multi-user setup.

@shirakaba
Copy link
Author

TODO: provision another user by following the How to set up a configuration for multiple users/machines? section of the home-manager docs.

@shirakaba
Copy link
Author

When setting up for a secondary user, I ran into an ownership problem reported by oh-my-zsh:

[oh-my-zsh] Insecure completion-dependent directories detected:
dr-xr-xr-x  3 jamie  staff   96  1 Jan  1970 /nix/var/nix/profiles/default/share/zsh
dr-xr-xr-x  3 jamie  staff   96  1 Jan  1970 /nix/var/nix/profiles/default/share/zsh/site-functions
-r--r--r--  1 jamie  staff  529  1 Jan  1970 /nix/var/nix/profiles/default/share/zsh/site-functions/_nix
[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.
[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh]     compaudit | xargs chmod g-w,o-w
[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.

I didn't want to mess with the Nix installation, so I set ZSH_DISABLE_COMPFIX=true as suggested:

programs.zsh = {
  enable = true;
  # Add bash completion on top of the default compinit.
  completionInit = ''
    autoload -U compinit
    compinit
    autoload -U select-word-style
    select-word-style bash
  '';
  envExtra = ''
    export ZSH_DISABLE_COMPFIX=true
    ${shellEnvCommon}
  '';
  oh-my-zsh = {
    enable = true;
    plugins = [
      "git"
      "sudo"
    ];
    theme = "robbyrussell";
  };
};

@shirakaba
Copy link
Author

shirakaba commented Jan 26, 2022

To install Volta (not managed by Nix):

curl https://get.volta.sh | bash -s -- --skip-setup

Then add to your shell env:

export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"

And finally install (here I choose the LTS) node:

volta install node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment