Improve Mac explain output (#205)
This commit is contained in:
parent
d74c61734a
commit
e81456673b
|
@ -15,7 +15,8 @@ const SOCKET_SRC: &str = "/nix/var/nix/profiles/default/lib/systemd/system/nix-d
|
||||||
const TMPFILES_SRC: &str = "/nix/var/nix/profiles/default/lib/tmpfiles.d/nix-daemon.conf";
|
const TMPFILES_SRC: &str = "/nix/var/nix/profiles/default/lib/tmpfiles.d/nix-daemon.conf";
|
||||||
const TMPFILES_DEST: &str = "/etc/tmpfiles.d/nix-daemon.conf";
|
const TMPFILES_DEST: &str = "/etc/tmpfiles.d/nix-daemon.conf";
|
||||||
const DARWIN_NIX_DAEMON_DEST: &str = "/Library/LaunchDaemons/org.nixos.nix-daemon.plist";
|
const DARWIN_NIX_DAEMON_DEST: &str = "/Library/LaunchDaemons/org.nixos.nix-daemon.plist";
|
||||||
|
const DARWIN_NIX_DAEMON_SOURCE: &str =
|
||||||
|
"/nix/var/nix/profiles/default/Library/LaunchDaemons/org.nixos.nix-daemon.plist";
|
||||||
/**
|
/**
|
||||||
Run systemd utilities to configure the Nix daemon
|
Run systemd utilities to configure the Nix daemon
|
||||||
*/
|
*/
|
||||||
|
@ -57,15 +58,30 @@ impl Action for ConfigureNixDaemonService {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_description(&self) -> Vec<ActionDescription> {
|
fn execute_description(&self) -> Vec<ActionDescription> {
|
||||||
vec![ActionDescription::new(
|
match OperatingSystem::host() {
|
||||||
|
OperatingSystem::MacOSX {
|
||||||
|
major: _,
|
||||||
|
minor: _,
|
||||||
|
patch: _,
|
||||||
|
}
|
||||||
|
| OperatingSystem::Darwin => vec![ActionDescription::new(
|
||||||
|
self.tracing_synopsis(),
|
||||||
|
vec![
|
||||||
|
format!("Copy `{DARWIN_NIX_DAEMON_SOURCE}` to `DARWIN_NIX_DAEMON_DEST`"),
|
||||||
|
format!("Run `launchctl load {DARWIN_NIX_DAEMON_DEST}`"),
|
||||||
|
],
|
||||||
|
)],
|
||||||
|
_ => vec![ActionDescription::new(
|
||||||
self.tracing_synopsis(),
|
self.tracing_synopsis(),
|
||||||
vec![
|
vec![
|
||||||
"Run `systemd-tempfiles --create --prefix=/nix/var/nix`".to_string(),
|
"Run `systemd-tempfiles --create --prefix=/nix/var/nix`".to_string(),
|
||||||
format!("Run `systemctl link {SERVICE_SRC}`"),
|
format!("Run `systemctl link {SERVICE_SRC}`"),
|
||||||
format!("Run `systemctl link {SOCKET_SRC}`"),
|
format!("Run `systemctl link {SOCKET_SRC}`"),
|
||||||
"Run `systemctl daemon-reload`".to_string(),
|
"Run `systemctl daemon-reload`".to_string(),
|
||||||
|
format!("Run `systemctl enable --now {SOCKET_SRC}`"),
|
||||||
],
|
],
|
||||||
)]
|
)],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
|
@ -79,7 +95,7 @@ impl Action for ConfigureNixDaemonService {
|
||||||
patch: _,
|
patch: _,
|
||||||
}
|
}
|
||||||
| OperatingSystem::Darwin => {
|
| OperatingSystem::Darwin => {
|
||||||
let src = Path::new("/nix/var/nix/profiles/default/Library/LaunchDaemons/org.nixos.nix-daemon.plist");
|
let src = Path::new(DARWIN_NIX_DAEMON_SOURCE);
|
||||||
tokio::fs::copy(src.clone(), DARWIN_NIX_DAEMON_DEST)
|
tokio::fs::copy(src.clone(), DARWIN_NIX_DAEMON_DEST)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
|
@ -167,7 +183,17 @@ impl Action for ConfigureNixDaemonService {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn revert_description(&self) -> Vec<ActionDescription> {
|
fn revert_description(&self) -> Vec<ActionDescription> {
|
||||||
vec![ActionDescription::new(
|
match OperatingSystem::host() {
|
||||||
|
OperatingSystem::MacOSX {
|
||||||
|
major: _,
|
||||||
|
minor: _,
|
||||||
|
patch: _,
|
||||||
|
}
|
||||||
|
| OperatingSystem::Darwin => vec![ActionDescription::new(
|
||||||
|
"Unconfigure Nix daemon related settings with launchd".to_string(),
|
||||||
|
vec!["Run `launchctl unload {DARWIN_NIX_DAEMON_DEST}`".to_string()],
|
||||||
|
)],
|
||||||
|
_ => 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(),
|
"Run `systemctl disable {SOCKET_SRC}`".to_string(),
|
||||||
|
@ -175,7 +201,8 @@ impl Action for ConfigureNixDaemonService {
|
||||||
"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(),
|
||||||
],
|
],
|
||||||
)]
|
)],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
|
|
Loading…
Reference in a new issue