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

darwin.rs: handle new root only activation #238

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

khaneliman
Copy link

@khaneliman khaneliman commented Mar 18, 2025

Closes #233

Basically, with the new nix-darwin rewrite everything is moved to root activation. I check if the nix-darwin user activation script contains the deprecation notice. If it does, we just call the activate script only. (Where the old user activation stuff has been moved) Also, moved to using the darwin-rebuild script instead of the activation scripts directly so that nix-darwin can handle migrations themselves and we don't have to worry about the current implementation details every time a change is made upstream. We just elevate the activate when it needs to be.

Marking draft until the deprecation marker is solidified in LnL7/nix-darwin#1341

Nix-darwin is being rewritted to move to root activation and deprecating
the user activation script. Check whether the script we are activating
with contains the deprecation notice.
In the future the script will be removed, if it does get removed we
should just call the `activate` script as root.
@khaneliman khaneliman marked this pull request as draft March 18, 2025 18:19
@khaneliman
Copy link
Author

Currently calls activation scripts directly, sounds like we should be using the darwin-rebuild binary instead.

@khaneliman khaneliman force-pushed the darwin branch 2 times, most recently from cdc466c to bb7d429 Compare March 18, 2025 19:01
Recommended to use the darwin-rebuild activate command by maintainers.
khaneliman added a commit to khaneliman/khanelinix that referenced this pull request Mar 18, 2025
Using nh fork with support for root activation until
viperML/nh#238 is merged, using nix-darwin fork
with the plan p1 changes until that's merged.

Command::new(switch_to_configuration)
.elevate(true)
let darwin_rebuild = out_path.get_path().join("sw/bin/darwin-rebuild");
Copy link

@isabelroses isabelroses Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this introduces a dependency on darwin-rebuild which is not always present.

If you can’t or don’t want to use darwin-rebuild activate, then you
should skip running activate-user for post‐user‐activation
configurations and continue running activate as root.

Copy link
Author

@khaneliman khaneliman Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situation is it not present? This is the darwin-rebuild from the built configuration.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was done from conversations with emilazy on matrix recommending i switch the implementation from using the activation scripts directly to the built darwin-rebuild binary.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situation is it not present? This is the darwin-rebuild from the built configuration.

system.tools.darwin-rebuild.enable = false

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn’t set system.tools.darwin-rebuild.enable on a system you want to switch configurations on. We should probably add a stronger warning to that option and maybe hide it, since it’s extremely niche. In the long run we will hopefully have separate apply/switch-to-configuration scripts, but currently I don’t think this is a configuration activation tools should worry about supporting.

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.

darwin: support new system activation
3 participants