Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3d2765c

Browse files
committedMar 18, 2025··
darwin.rs: handle new root only activation
1 parent 509dd6c commit 3d2765c

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed
 

‎src/darwin.rs

+19-10
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,32 @@ impl DarwinRebuildArgs {
135135
.args(["build", "--no-link", "--profile", SYSTEM_PROFILE])
136136
.arg(out_path.get_path())
137137
.elevate(true)
138-
.dry(self.common.dry)
139-
.run()?;
138+
.dry(self.common.dry);
140139

141-
let switch_to_configuration = out_path.get_path().join("activate-user");
140+
let activate_user = out_path.get_path().join("activate-user");
142141

143-
Command::new(switch_to_configuration)
142+
let user_activation = Command::new(activate_user.clone())
144143
.message("Activating configuration for user")
145-
.dry(self.common.dry)
146-
.run()?;
144+
.dry(self.common.dry);
147145

148-
let switch_to_configuration = out_path.get_path().join("activate");
146+
let activate = out_path.get_path().join("activate");
149147

150-
Command::new(switch_to_configuration)
148+
let activation = Command::new(activate)
151149
.elevate(true)
152150
.message("Activating configuration")
153-
.dry(self.common.dry)
154-
.run()?;
151+
.dry(self.common.dry);
152+
153+
// Check whether to activate-user is deprecated
154+
// If it is, only activate with root
155+
if std::fs::read_to_string(&activate_user)
156+
.context("Failed to read activate-user file")?
157+
.contains("# nix-darwin: deprecated")
158+
{
159+
activation.run()?;
160+
} else {
161+
user_activation.run()?;
162+
activation.run()?;
163+
}
155164
}
156165

157166
// Make sure out_path is not accidentally dropped

0 commit comments

Comments
 (0)
Please sign in to comment.