File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change 1616 support legacy/vulnerable versions of Nix, and encourage users to update if
1717 they have not yet done so.
1818
19+ ### Changed
20+
21+ - Darwin: Use ` darwin-rebuild ` directly for activation instead of old scripts
22+ - Darwin: Future-proof handling of ` activate-user ` script removal
23+ - Darwin: Improve compatibility with root-only activation in newer nix-darwin versions
24+
1925## 4.0.3
2026
2127### Added
Original file line number Diff line number Diff line change @@ -129,18 +129,22 @@ impl DarwinRebuildArgs {
129129 . dry ( self . common . dry )
130130 . run ( ) ?;
131131
132- let switch_to_configuration = out_path. get_path ( ) . join ( "activate-user" ) ;
133-
134- Command :: new ( switch_to_configuration)
135- . message ( "Activating configuration for user" )
136- . dry ( self . common . dry )
137- . run ( ) ?;
138-
139- let switch_to_configuration = out_path. get_path ( ) . join ( "activate" ) ;
140-
141- Command :: new ( switch_to_configuration)
142- . elevate ( true )
132+ let darwin_rebuild = out_path. get_path ( ) . join ( "sw/bin/darwin-rebuild" ) ;
133+ let activate_user = out_path. get_path ( ) . join ( "activate-user" ) ;
134+
135+ // Determine if we need to elevate privileges
136+ let needs_elevation = !activate_user
137+ . try_exists ( )
138+ . context ( "Failed to check if activate-user file exists" ) ?
139+ || std:: fs:: read_to_string ( & activate_user)
140+ . context ( "Failed to read activate-user file" ) ?
141+ . contains ( "# nix-darwin: deprecated" ) ;
142+
143+ // Create and run the activation command with or without elevation
144+ Command :: new ( darwin_rebuild)
145+ . arg ( "activate" )
143146 . message ( "Activating configuration" )
147+ . elevate ( needs_elevation)
144148 . dry ( self . common . dry )
145149 . run ( ) ?;
146150 }
You can’t perform that action at this time.
0 commit comments