Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New nix-darwin install - "error: file 'darwin' was not found in the Nix search path (add it using $NIX_PATH or -I)" #1360

Open
victorhooi opened this issue Mar 4, 2025 · 5 comments

Comments

@victorhooi
Copy link

victorhooi commented Mar 4, 2025

I'm trying to setup Nix on a new macOS machine (running macOS Sequoia 15.3.1), and I'm hitting some PATH errors trying to get nix-darwin to install. (I'm a Nix newbie - previously I was using the starter templates from here, but I figured I wanted to try some of it myself).

Firstly, I installed Nix using the Determinate Nix installer:

victorhooi@MacBook-Pro ~ % curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
  sh -s -- install
info: downloading installer https://install.determinate.systems/nix/tag/v0.38.1/nix-installer-aarch64-darwin
 INFO nix-installer v0.38.1
`nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
 INFO nix-installer v0.38.1
 INFO For a more robust Nix installation, use the Determinate package for macOS: https://dtr.mn/determinate-nix

Install Determinate Nix?

Proceed? ([Y]es/[n]o/[e]xplain): yes
Nix install plan (v0.38.1)
Planner: macos

Configured settings:
* determinate_nix: true

Planned actions:
* Install Determinate Nixd
* Create an encrypted APFS volume `Nix Store` for Nix on `disk3` and add it to `/etc/fstab` mounting on `/nix`
* Extract the bundled Nix (originally from /nix/store/1q9hil0gipfxndz3pq6jg4ggmn0syia8-nix-binary-tarball-2.26.2/nix-2.26.2-aarch64-darwin.tar.xz)
* Create a directory tree in `/nix`
* Synchronize /nix/var ownership
* Move the downloaded Nix into `/nix`
* Synchronize /nix/store ownership
* Create build users (UID 351-382) and group (GID 350)
* Configure Time Machine exclusions
* Setup the default Nix profile
* Place the Nix configuration in `/etc/nix/nix.conf`
* Configure the shell profiles
* Configuring zsh to support using Nix in non-interactive shells
* Create a `launchctl` plist to put Nix into your PATH
* Configure the Determinate Nix daemon
* Remove directory `/nix/temp-install-dir`


Proceed? ([Y]es/[n]o/[e]xplain): yes
 INFO Step: Install Determinate Nixd
 INFO Step: Create an encrypted APFS volume `Nix Store` for Nix on `disk3` and add it to `/etc/fstab` mounting on `/nix`
 INFO Step: Provision Nix
 INFO Step: Create build users (UID 351-382) and group (GID 350)
 INFO Step: Configure Time Machine exclusions
 INFO Step: Configure Nix
 INFO Step: Configuring zsh to support using Nix in non-interactive shells
 INFO Step: Create a `launchctl` plist to put Nix into your PATH
 INFO Step: Configure the Determinate Nix daemon
 INFO Step: Remove directory `/nix/temp-install-dir`
Nix was installed successfully!
To get started using Nix, open a new shell or run `. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh`

Then, I created a Nix configuration directly at ~/.config/nix, and created a flake.nix using the nix-darwin template:

victorhooi@MacBook-Pro nix % nix flake init -t nix-darwin/master
wrote: "/Users/victorhooi/.config/nix/flake.nix"

Then I edited the hostname using the snippet from the nix-darwin README:

victorhooi@MacBook-Pro nix % sed -i '' "s/simple/$(scutil --get LocalHostName)/" flake.nix

Finally I ran the nix-darwin install command from the README - this is where it seems to error out around the path:

victorhooi@MacBook-Pro nix % nix run nix-darwin/master#darwin-rebuild -- switch

building the system configuration...
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: file 'darwin' was not found in the Nix search path (add it using $NIX_PATH or -I)

I did try spawning a new shell, but I get the same error:

victorhooi@MacBook-Pro nix % nix run nix-darwin/master#darwin-rebuild -- switch
building the system configuration...
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
error: file 'darwin' was not found in the Nix search path (add it using $NIX_PATH or -I)

UPDATE:

I'm using the default zsh in macOS (although I'd like to switch to fish shortly - or possibly try out nushell...lol).

This is my current $PATH:

victorhooi@MacBook-Pro nix % echo $PATH
/Users/victorhooi/.bun/bin:/Users/victorhooi/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
@victorhooi
Copy link
Author

Hmm - I think my issue might be this one:

#1330

However, I think the README is a little ambigious (as is the README).

I'm still a bit hazy as to why I should be using /etc/nix-darwin as my Nix flake configuration directory - other sources online mention using ~/.config/nix, and other guides seem to put it in other places. However, is /etc/nix-darwin meant to be the proper place?

@TechAssistance
Copy link

Same exact issue here. Set config to ~/.config/nix/flake.nix

When trying to run nix run nix-darwin/master#darwin-rebuild --extra-experimental-features "nix-command flakes" -- switch
I get the same error regarding the path. Although I did not install nix using the installer (yay me seems like uninstalling will suck lol).

@TechAssistance
Copy link

Issue resolved by declaring --flake ~/.config/nix/flake.nix in the command per this comment.

I think we will need to update the installation instructions or make some better Quickstart docs as this seems to be something changed form a vast majority of existing external guides.

@Enzime
Copy link
Member

Enzime commented Mar 5, 2025

I've made a PR to clarify this in the README, please let me know if the wording is clear https://github.com/LnL7/nix-darwin/pull/1368/files

@TechAssistance
Copy link

Added a comment / recommendation that we make known the --flake option as many users will want to use the .config/nix location anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants