parent
89094e0d40
commit
c55a59b10e
|
@ -292,8 +292,8 @@ impl Action for ConfigureInitService {
|
||||||
vec![ActionDescription::new(
|
vec![ActionDescription::new(
|
||||||
"Unconfigure Nix daemon related settings with systemd".to_string(),
|
"Unconfigure Nix daemon related settings with systemd".to_string(),
|
||||||
vec![
|
vec![
|
||||||
"Run `systemctl disable {SOCKET_SRC}`".to_string(),
|
format!("Run `systemctl disable {SOCKET_SRC}`"),
|
||||||
"Run `systemctl disable {SERVICE_SRC}`".to_string(),
|
format!("Run `systemctl disable {SERVICE_SRC}`"),
|
||||||
"Run `systemd-tempfiles --remove --prefix=/nix/var/nix`".to_string(),
|
"Run `systemd-tempfiles --remove --prefix=/nix/var/nix`".to_string(),
|
||||||
"Run `systemctl daemon-reload`".to_string(),
|
"Run `systemctl daemon-reload`".to_string(),
|
||||||
],
|
],
|
||||||
|
|
|
@ -198,6 +198,7 @@ impl CommandExecute for Install {
|
||||||
match interaction::prompt(
|
match interaction::prompt(
|
||||||
install_plan
|
install_plan
|
||||||
.describe_uninstall(currently_explaining)
|
.describe_uninstall(currently_explaining)
|
||||||
|
.await
|
||||||
.map_err(|e| eyre!(e))?,
|
.map_err(|e| eyre!(e))?,
|
||||||
PromptChoice::Yes,
|
PromptChoice::Yes,
|
||||||
currently_explaining,
|
currently_explaining,
|
||||||
|
|
|
@ -106,6 +106,7 @@ impl CommandExecute for Uninstall {
|
||||||
loop {
|
loop {
|
||||||
match interaction::prompt(
|
match interaction::prompt(
|
||||||
plan.describe_uninstall(currently_explaining)
|
plan.describe_uninstall(currently_explaining)
|
||||||
|
.await
|
||||||
.map_err(|e| eyre!(e))?,
|
.map_err(|e| eyre!(e))?,
|
||||||
PromptChoice::Yes,
|
PromptChoice::Yes,
|
||||||
currently_explaining,
|
currently_explaining,
|
||||||
|
|
83
src/plan.rs
83
src/plan.rs
|
@ -90,24 +90,24 @@ impl InstallPlan {
|
||||||
let buf = format!(
|
let buf = format!(
|
||||||
"\
|
"\
|
||||||
Nix install plan (v{version})\n\
|
Nix install plan (v{version})\n\
|
||||||
\n\
|
Planner: {planner}{maybe_default_setting_note}\n\
|
||||||
Planner: {planner}\n\
|
|
||||||
\n\
|
\n\
|
||||||
{maybe_plan_settings}\
|
{maybe_plan_settings}\
|
||||||
\
|
Planned actions:\n\
|
||||||
The following actions will be taken:\n\
|
|
||||||
\n\
|
|
||||||
{actions}\n\
|
{actions}\n\
|
||||||
",
|
",
|
||||||
planner = planner.typetag_name(),
|
planner = planner.typetag_name(),
|
||||||
|
maybe_default_setting_note = if plan_settings.is_empty() {
|
||||||
|
String::from(" (with default settings)")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
},
|
||||||
maybe_plan_settings = if plan_settings.is_empty() {
|
maybe_plan_settings = if plan_settings.is_empty() {
|
||||||
String::new()
|
String::new()
|
||||||
} else {
|
} else {
|
||||||
// TODO: "Changed planner settings"?
|
|
||||||
format!(
|
format!(
|
||||||
"\
|
"\
|
||||||
Planner settings:\n\
|
Configured settings:\n\
|
||||||
\n\
|
|
||||||
{plan_settings}\n\
|
{plan_settings}\n\
|
||||||
\n\
|
\n\
|
||||||
",
|
",
|
||||||
|
@ -213,39 +213,56 @@ impl InstallPlan {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
pub fn describe_uninstall(&self, explain: bool) -> Result<String, NixInstallerError> {
|
pub async fn describe_uninstall(&self, explain: bool) -> Result<String, NixInstallerError> {
|
||||||
let Self {
|
let Self {
|
||||||
version: _,
|
version,
|
||||||
planner,
|
planner,
|
||||||
actions,
|
actions,
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
let buf = format!(
|
|
||||||
"\
|
let plan_settings = if explain {
|
||||||
Nix uninstall plan\n\
|
// List all settings when explaining
|
||||||
\n\
|
planner.settings()?
|
||||||
Planner: {planner}\n\
|
|
||||||
\n\
|
|
||||||
Planner settings:\n\
|
|
||||||
\n\
|
|
||||||
{plan_settings}\n\
|
|
||||||
\n\
|
|
||||||
The following actions will be taken{maybe_explain}:\n\
|
|
||||||
\n\
|
|
||||||
{actions}\n\
|
|
||||||
",
|
|
||||||
maybe_explain = if !explain {
|
|
||||||
" (`--explain` for more context)"
|
|
||||||
} else {
|
} else {
|
||||||
""
|
// Otherwise, only list user-configured settings
|
||||||
},
|
planner.configured_settings().await?
|
||||||
planner = planner.typetag_name(),
|
};
|
||||||
plan_settings = planner
|
let mut plan_settings = plan_settings
|
||||||
.settings()?
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(k, v)| format!("* {k}: {v}", k = k.bold()))
|
.map(|(k, v)| format!("* {k}: {v}", k = k.bold()))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>();
|
||||||
.join("\n"),
|
// Stabilize output order
|
||||||
|
plan_settings.sort();
|
||||||
|
|
||||||
|
let buf = format!(
|
||||||
|
"\
|
||||||
|
Nix uninstall plan (v{version})\n\
|
||||||
|
\n\
|
||||||
|
Planner: {planner}{maybe_default_setting_note}\n\
|
||||||
|
\n\
|
||||||
|
{maybe_plan_settings}\
|
||||||
|
Planned actions:\n\
|
||||||
|
{actions}\n\
|
||||||
|
",
|
||||||
|
planner = planner.typetag_name(),
|
||||||
|
maybe_default_setting_note = if plan_settings.is_empty() {
|
||||||
|
String::from(" (with default settings)")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
},
|
||||||
|
maybe_plan_settings = if plan_settings.is_empty() {
|
||||||
|
String::new()
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"\
|
||||||
|
Configured settings:\n\
|
||||||
|
{plan_settings}\n\
|
||||||
|
\n\
|
||||||
|
",
|
||||||
|
plan_settings = plan_settings.join("\n")
|
||||||
|
)
|
||||||
|
},
|
||||||
actions = actions
|
actions = actions
|
||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
|
|
Loading…
Reference in a new issue