Skip to content

Commit

Permalink
Minor macOS code fixups (#1346)
Browse files Browse the repository at this point in the history
* CreateNixVolume: use constant for darwin-store service label

* BootstrapLaunchctlService: remove exit code 37 check

This is returned with the message "Operation already in progress".
However, `print` doesn't actually start anything, so I highly doubt this
can ever trigger. This has existed since the beginning of this file, but
I believe it's a relic of some leftover testing with `launchctl load` /
`launchctl unload` / `launchctl bootstrap` / `launchctl bootout`, which
likely could return this.
  • Loading branch information
cole-h authored Dec 11, 2024
1 parent 82a6444 commit cdc3a34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/action/macos/bootstrap_launchctl_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl BootstrapLaunchctlService {
.await
.map_err(|e| Self::error(ActionErrorKind::command(&command, e)))?;
// We presume that success means it's found
command_output.status.success() || command_output.status.code() == Some(37)
command_output.status.success()
};

let is_disabled = service_is_disabled(DARWIN_LAUNCHD_DOMAIN, &service)
Expand Down
7 changes: 4 additions & 3 deletions src/action/macos/create_nix_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use super::{
};

pub const NIX_VOLUME_MOUNTD_DEST: &str = "/Library/LaunchDaemons/org.nixos.darwin-store.plist";
pub const NIX_VOLUME_MOUNTD_NAME: &str = "org.nixos.darwin-store";

/// Create an APFS volume
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
Expand Down Expand Up @@ -88,7 +89,7 @@ impl CreateNixVolume {

let setup_volume_daemon = CreateVolumeService::plan(
NIX_VOLUME_MOUNTD_DEST,
"org.nixos.darwin-store",
NIX_VOLUME_MOUNTD_NAME,
name.clone(),
"/nix",
encrypt,
Expand All @@ -97,11 +98,11 @@ impl CreateNixVolume {
.map_err(Self::error)?;

let bootstrap_volume =
BootstrapLaunchctlService::plan("org.nixos.darwin-store", NIX_VOLUME_MOUNTD_DEST)
BootstrapLaunchctlService::plan(NIX_VOLUME_MOUNTD_NAME, NIX_VOLUME_MOUNTD_DEST)
.await
.map_err(Self::error)?;
let kickstart_launchctl_service =
KickstartLaunchctlService::plan(DARWIN_LAUNCHD_DOMAIN, "org.nixos.darwin-store")
KickstartLaunchctlService::plan(DARWIN_LAUNCHD_DOMAIN, NIX_VOLUME_MOUNTD_NAME)
.await
.map_err(Self::error)?;
let enable_ownership = EnableOwnership::plan("/nix").await.map_err(Self::error)?;
Expand Down

0 comments on commit cdc3a34

Please sign in to comment.