nix icon indicating copy to clipboard operation
nix copied to clipboard

Nix Package Manager Installation stuck at `launchctl kickstart -k system/org.nixos.darwin-store` on Mac

Open Riley1101 opened this issue 1 year ago • 3 comments

Platform

  • [ ] Linux:
  • [X] macOS
  • [ ] WSL

Additional information

I have been trying to install Nix package manger on my Mac and its stuck at this , I have tried like restarting os, removing packages and the installer just hung at that stage.

macOS 14.4.1 23E224 arm64
Host: Mac15,7
Kernel: 23.4.0
CPU: Apple M3 Pro
GPU: Apple M3 Pro
Terminal: tmux

Output

Output

  % 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  4267  100  4267    0     0  22471      0 --:--:-- --:--:-- --:--:-- 22471
downloading Nix 2.24.9 binary tarball for aarch64-darwin from 'https://releases.nixos.org/nix/nix-2.24.9/nix-2.24.9-aarch64-darwin.tar.xz' to '/var/folders/1h/v1kpyk6d57d80785fnxhgdmh0000gp/T/nix-binary-tarball-unpack.XXXXXXXXXX.dqIv2n37Jc'...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14.6M  100 14.6M    0     0  40.4M      0 --:--:-- --:--:-- --:--:-- 40.4M
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 I am going to install and where. Then I will ask
   if you are ready to continue.

3. Create the system users (uids [351..382]) and groups (gid 350)
   that the Nix daemon uses to run builds. To create system users
   in a different range, exit and run this tool again with
   NIX_FIRST_BUILD_UID set.

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 I will do?
[y/n] y


I 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 I'll make)
 - create a local group (nixbld)
 - install Nix in /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
 - back up /etc/bash.bashrc to /etc/bash.bashrc.backup-before-nix
 - update /etc/bash.bashrc 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 I 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. I 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 I 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.

---- Found existing Nix volume -------------------------------------------------
  special:      disk3s7
     uuid:      EE3BA4D5-F6CF-4759-8FD8-6CC4DE362718
encrypted:      no

During install, I add 'nix' to /etc/synthetic.conf, which instructs
macOS to create an empty root directory for mounting the Nix volume.
Can I remove /etc/synthetic.conf?
[y/n] y


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

    $ sudo rm /etc/synthetic.conf

to remove /etc/synthetic.conf

Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
During install, I add '/nix' to /etc/fstab so that macOS knows what
mount options to use for the Nix volume.
Can I remove /etc/fstab?
[y/n] y


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

    $ sudo rm /etc/fstab

to remove /etc/fstab


The installer adds a LaunchDaemon to mount your Nix volume: org.nixos.darwin-store
Can I remove it?
[y/n] y


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

    $ sudo launchctl bootout system/org.nixos.darwin-store

to terminate the daemon


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

    $ sudo rm /Library/LaunchDaemons/org.nixos.darwin-store.plist

to remove the daemon definition


~~> Checking for artifacts of previous installs
Before I try to install, I'll check for signs Nix already is or has
been installed on this system.

---- Nix config report ---------------------------------------------------------
        Temp Dir:       /var/folders/1h/v1kpyk6d57d80785fnxhgdmh0000gp/T/tmp.vIKU8mzQwZ
        Nix Root:       /nix
     Build Users:       32
  Build Group ID:       350
Build Group Name:       nixbld

build users:
    Username:   UID
     _nixbld1:  351
     _nixbld2:  352
     _nixbld3:  353
     _nixbld4:  354
     _nixbld5:  355
     _nixbld6:  356
     _nixbld7:  357
     _nixbld8:  358
     _nixbld9:  359
     _nixbld10: 360
     _nixbld11: 361
     _nixbld12: 362
     _nixbld13: 363
     _nixbld14: 364
     _nixbld15: 365
     _nixbld16: 366
     _nixbld17: 367
     _nixbld18: 368
     _nixbld19: 369
     _nixbld20: 370
     _nixbld21: 371
     _nixbld22: 372
     _nixbld23: 373
     _nixbld24: 374
     _nixbld25: 375
     _nixbld26: 376
     _nixbld27: 377
     _nixbld28: 378
     _nixbld29: 379
     _nixbld30: 380
     _nixbld31: 381
     _nixbld32: 382

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 -u NONE -n /etc/synthetic.conf

to add Nix to /etc/synthetic.conf


~~> Creating a Nix volume

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

    $ sudo /usr/sbin/diskutil unmount force disk3s7

to ensure the Nix volume is not mounted

disk3s7 was already unmounted

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

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

    $ sudo /usr/sbin/vifs

to add nix to fstab


~~> Configuring LaunchDaemon to mount 'Nix Store'

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

    $ sudo /usr/bin/ex -u NONE -n /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

Priorities

Add :+1: to issues you find important.

Riley1101 avatar Oct 17 '24 14:10 Riley1101

It may actually be getting stuck right after. Can you take a look at the query in https://github.com/NixOS/nix/issues/5938#issuecomment-1016040203 and report back?

abathur avatar Oct 17 '24 18:10 abathur

Hey, I tried via the comments looks like its similar to comment in #5938

~ » /usr/sbin/diskutil info /nix                                                                                                                1 ↵ amyat@FMG-HWVT4QCPHY
Could not find disk: /nix
~/ » /usr/sbin/diskutil apfs list                                                               
 user@machine
APFS Containers (3 found)
|
+-- Container disk3 E07EF79F-5162-41D8-AC37-1BA34590D088
    ====================================================
    APFS Container Reference:     disk3
    Size (Capacity Ceiling):      494384795648 B (494.4 GB)
    Capacity In Use By Volumes:   342564880384 B (342.6 GB) (69.3% used)
    Capacity Not Allocated:       151819915264 B (151.8 GB) (30.7% free)
    |
    +-< Physical Store disk0s2 FB0CE5F2-03BA-424A-BA34-1373F7EBDD41
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk0s2
    |   Size:                       494384795648 B (494.4 GB)
    |
    +-> Volume disk3s1 6AF86E5B-2C16-4884-8798-D0D2CAA89233
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s1 (System)
    |   Name:                      Macintosh HD (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         13474029568 B (13.5 GB)
    |   Sealed:                    Broken
    |   FileVault:                 No (Encrypted at rest)
    |   |
    |   Snapshot:                  D9D3D392-522B-4943-8444-6C39C639B60F
    |   Snapshot Disk:             disk3s1s1
    |   Snapshot Mount Point:      /
    |   Snapshot Sealed:           Yes
    |
    +-> Volume disk3s2 8DF38F62-1B65-42FF-9F0F-742AEE8FD0B3
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s2 (Preboot)
    |   Name:                      Preboot (Case-insensitive)
    |   Mount Point:               /System/Volumes/Preboot
    |   Capacity Consumed:         12261519360 B (12.3 GB)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk3s3 B4DA8920-4418-481F-BEF2-A0FFA898FCA4
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s3 (Recovery)
    |   Name:                      Recovery (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         1873219584 B (1.9 GB)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk3s5 A1BDFB26-9263-4DDB-802A-DEBBCCC35EED
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s5 (Data)
    |   Name:                      Data (Case-insensitive)
    |   Mount Point:               /System/Volumes/Data
    |   Capacity Consumed:         311981977600 B (312.0 GB)
    |   Sealed:                    No
    |   FileVault:                 No (Encrypted at rest)
    |
    +-> Volume disk3s6 A9367B47-5A78-4E83-AF02-750575F8CE4B
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s6 (VM)
    |   Name:                      VM (Case-insensitive)
    |   Mount Point:               /System/Volumes/VM
    |   Capacity Consumed:         2147504128 B (2.1 GB)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk3s7 EE3BA4D5-F6CF-4759-8FD8-6CC4DE362718
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk3s7 (No specific role)
        Name:                      Nix Store (Case-insensitive)
        Mount Point:               Not Mounted
        Capacity Consumed:         24576 B (24.6 KB)
        Sealed:                    No
        FileVault:                 No (Encrypted at rest)

And /nix is there

~/ » ls -ld /nix                                                                                              
 user@machine
drwxr-xr-x  2 root  wheel  64 Oct 16 09:30 /nix

I also tried running this alone and it run passed smoothly.

~/.config/nvim (main*) » sudo launchctl kickstart -k system/org.nixos.darwin-store                                                                                       user@machine
Password:

I also found one thing Looks like the script is stuck at await_volume https://github.com/NixOS/nix/blob/1cd48008f0e31b0d48ad745b69256d881201e5ee/scripts/create-darwin-volume.sh#L786-L791

await_volume() {
    # caution: this could, in theory, get stuck
    until /usr/sbin/diskutil info "$NIX_ROOT" &>/dev/null; do
        :
    done
}

Not sure if this could help.

My $NIXROOT is empty.

Screenshot 2024-10-17 at 3 25 40 PM

Riley1101 avatar Oct 17 '24 19:10 Riley1101

Roughly by design. It's an indication that the mounting service is failing to mount your store volume.

$NIX_ROOT is only set within the installer, so that's not a problem.

I guess I'd recommend following the uninstall instructions, reboot, and then try reinstalling it: https://nixos.org/manual/nix/stable/installation/uninstall.html#macos

If that doesn't fix it, it should at least help focus the search a little.

abathur avatar Oct 17 '24 19:10 abathur

Hey, @abathur. I did removing the entire thing and reinstall a couple times. and still not working. Do you have any advice on which area should i tackle to make this work. I am dying to use nix on my mac. FYI i am using this on my cooperate controlled mac with full permission. Do you think this might relate ?

Riley1101 avatar Nov 21 '24 18:11 Riley1101