nix: Set profile only with certain goals
This commit is contained in:
parent
480d7ea5a1
commit
d99089ad6b
2 changed files with 19 additions and 7 deletions
|
@ -86,11 +86,13 @@ impl Host for Local {
|
||||||
}
|
}
|
||||||
async fn activate(&mut self, profile: &StorePath, goal: DeploymentGoal) -> NixResult<()> {
|
async fn activate(&mut self, profile: &StorePath, goal: DeploymentGoal) -> NixResult<()> {
|
||||||
let profile = profile.as_path().to_str().unwrap();
|
let profile = profile.as_path().to_str().unwrap();
|
||||||
|
if goal.should_switch_profile() {
|
||||||
Command::new("nix-env")
|
Command::new("nix-env")
|
||||||
.args(&["--profile", SYSTEM_PROFILE])
|
.args(&["--profile", SYSTEM_PROFILE])
|
||||||
.args(&["--set", profile])
|
.args(&["--set", profile])
|
||||||
.passthrough()
|
.passthrough()
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
let activation_command = format!("{}/bin/switch-to-configuration", profile);
|
let activation_command = format!("{}/bin/switch-to-configuration", profile);
|
||||||
Command::new(activation_command)
|
Command::new(activation_command)
|
||||||
|
@ -133,8 +135,10 @@ impl Host for SSH {
|
||||||
async fn activate(&mut self, profile: &StorePath, goal: DeploymentGoal) -> NixResult<()> {
|
async fn activate(&mut self, profile: &StorePath, goal: DeploymentGoal) -> NixResult<()> {
|
||||||
let profile = profile.as_path().to_str().unwrap();
|
let profile = profile.as_path().to_str().unwrap();
|
||||||
|
|
||||||
|
if goal.should_switch_profile() {
|
||||||
let set_profile = self.ssh(&["nix-env", "--profile", SYSTEM_PROFILE, "--set", profile]);
|
let set_profile = self.ssh(&["nix-env", "--profile", SYSTEM_PROFILE, "--set", profile]);
|
||||||
self.run_command(set_profile).await?;
|
self.run_command(set_profile).await?;
|
||||||
|
}
|
||||||
|
|
||||||
let activation_command = format!("{}/bin/switch-to-configuration", profile);
|
let activation_command = format!("{}/bin/switch-to-configuration", profile);
|
||||||
let command = self.ssh(&[&activation_command, goal.as_str().unwrap()]);
|
let command = self.ssh(&[&activation_command, goal.as_str().unwrap()]);
|
||||||
|
|
|
@ -207,6 +207,14 @@ impl DeploymentGoal {
|
||||||
DryActivate => Some("Dry activation successful"),
|
DryActivate => Some("Dry activation successful"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn should_switch_profile(&self) -> bool {
|
||||||
|
use DeploymentGoal::*;
|
||||||
|
match self {
|
||||||
|
Boot | Switch => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NixInstantiate<'hive> {
|
struct NixInstantiate<'hive> {
|
||||||
|
|
Loading…
Reference in a new issue