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] treewide: add checks for nix.enable #1340

Merged
merged 11 commits into from
Feb 14, 2025

Conversation

emilazy
Copy link
Collaborator

@emilazy emilazy commented Feb 14, 2025

Backport of #1332, with the inapplicable d677e3e omitted and conflicts resolved. Tested with nix.enable on and off.


Note: This work was funded by Determinate Systems.

This was added to Nixpkgs in eb8b70c020e6693b29634660fa173d7f14f882eb.

(cherry picked from commit fc9367a)
This was added to Nixpkgs in eb8b70c020e6693b29634660fa173d7f14f882eb.

(cherry picked from commit 0176a50)
(cherry picked from commit 7cca8f9)
(cherry picked from commit 147ed95)
(cherry picked from commit aba0c60)
(cherry picked from commit f4e2805)
(cherry picked from commit e3bde15)
(cherry picked from commit 42e16f3)
When we’re not managing the Nix installation, these defaults
aren’t used out of the box and won’t accurately represent the
state of any unmanaged Nix or the desired Nix package, so reading
the option defaults is a bug.

This was previously a warning for `nix.package` and a silent failure
for all the others. Now that all the problematic accesses in nix-darwin
have been appropriately conditionalized, and since a throw gives a
backtrace where a warning doesn’t, give throwing defaults to all the
`nix.*` options that don’t reflect reality and that that modules
shouldn’t be reading when `nix.enable` is off.

I’m not in love with the implementation strategy here… ideally
we’d think of something better than this and then upstream it to
NixOS. `nix.nrBuildUsers` growing a fake default that is never used
is particularly unfortunate. But this should hopefully catch mistakes
in module code reasonably reliably.

(cherry picked from commit cd445c5)
When `nix.enable` is off, we don’t necessarily have an active
Nix installation, so there won’t necessarily be an active
`/nix/var/nix/gcroots` directory to link things into. NixOS just skips
this unconditionally when `nix.enable` is off, but that doesn’t
work well with a context in which we usually expect `nix.enable`
to be coupled with an unmanaged system installation of Nix.

(cherry picked from commit 731910a)
@emilazy emilazy requested a review from Enzime February 14, 2025 16:54
@emilazy emilazy merged commit 3538464 into LnL7:nix-darwin-24.11 Feb 14, 2025
3 checks passed
@emilazy emilazy deleted the push-ykqknxqmlvmm branch February 14, 2025 17:20
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