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

[24.11] nix: add nix.enable option to disable Nix management #1326

Merged
merged 7 commits into from
Feb 11, 2025

Conversation

emilazy
Copy link
Collaborator

@emilazy emilazy commented Feb 7, 2025

Backport of #1278 and #1313, with the breaking changes omitted and some changes to accommodate that.


Note: This work was funded by Determinate Systems.

(cherry picked from commit e197661)
This is an equivalent of the `nix.enable` option from NixOS
and Home Manager. On NixOS, it mostly serves to allow building
fixed‐configuration systems without any Nix installation at
all. It should work for that purpose with nix-darwin too, and the
implementation is largely the same, but the main use case is more
similar to the Home Manager option: to allow the use of nix-darwin
with an unmanaged system installation of Nix, including when there
is another service expecting to manage it, as with Determinate.

By providing an escape hatch to opt out of Nix management entirely,
this will also allow us to consolidate and simplify our existing Nix
installation management, by being more opinionated about things like
taking ownership of the daemon and the build users. Porting one option
from NixOS lets us drop two that only ever existed in nix-darwin and
reduce overall complexity.

(cherry picked from commit e182d8d)
Currently, the `bin` directory of the configured system
is embedded in the `$PATH` of activation scripts, but not
other elements of the default `environment.systemPath` like
`/nix/var/nix/profiles/default/bin` or `/usr/local/bin`. This
means that when nix-darwin is not managing the Nix installation,
activation scripts like Home Manager’s that want to look up the
system‐managed Nix can’t find it. Search for it on the entire
`environment.systemPath` and add the appropriate directory if found.

We leave the launchd `activate-system` daemon alone, because it has
erroneously referred to `@out@/sw/bin` forever and therefore never got
a Nix on the path to begin with. That’s a problem for another time.

(The more ideal solution is probably for Home Manager activation to
be driven by launchd or something, but that’s a longer‐term goal.)

(cherry picked from commit fb2bc03)
This provides a more useful error message than the `/etc/nix/nix.conf`
hash mismatch error that would otherwise occur.

(cherry picked from commit 0387775)
Ideally we’d have separate manuals per release, but in the meantime
this should help avoid user confusion.
@emilazy emilazy requested a review from Enzime February 7, 2025 22:07
@emilazy emilazy merged commit f81c161 into LnL7:nix-darwin-24.11 Feb 11, 2025
3 checks passed
@emilazy emilazy deleted the push-kmnlnvvnortv branch February 11, 2025 19:30
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

Successfully merging this pull request may close these issues.

2 participants