Skip to content

Commit

Permalink
CreateNixVolume: name -> volume_label
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h committed Dec 9, 2024
1 parent 9fc7084 commit 68a27d5
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/action/macos/create_nix_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub const NIX_VOLUME_MOUNTD_NAME: &str = "org.nixos.darwin-store";
#[serde(tag = "action_name", rename = "create_nix_volume")]
pub struct CreateNixVolume {
disk: PathBuf,
name: String,
volume_label: String,
case_sensitive: bool,
encrypt: bool,
create_or_append_synthetic_conf: StatefulAction<CreateOrInsertIntoFile>,
Expand All @@ -45,7 +45,7 @@ impl CreateNixVolume {
#[tracing::instrument(level = "debug", skip_all)]
pub async fn plan(
disk: impl AsRef<Path>,
name: String,
volume_label: String,
case_sensitive: bool,
encrypt: bool,
) -> Result<StatefulAction<Self>, ActionError> {
Expand All @@ -63,34 +63,34 @@ impl CreateNixVolume {

let create_synthetic_objects = CreateSyntheticObjects::plan().await.map_err(Self::error)?;

let create_volume = CreateApfsVolume::plan(disk, name.clone(), case_sensitive)
let create_volume = CreateApfsVolume::plan(disk, volume_label.clone(), case_sensitive)
.await
.map_err(Self::error)?;

let unmount_volume = if create_volume.state == crate::action::ActionState::Completed {
UnmountApfsVolume::plan_skip_if_already_mounted_to_nix(disk, name.clone())
UnmountApfsVolume::plan_skip_if_already_mounted_to_nix(disk, volume_label.clone())
.await
.map_err(Self::error)?
} else {
UnmountApfsVolume::plan(disk, name.clone())
UnmountApfsVolume::plan(disk, volume_label.clone())
.await
.map_err(Self::error)?
};

let create_fstab_entry = CreateFstabEntry::plan(name.clone())
let create_fstab_entry = CreateFstabEntry::plan(volume_label.clone())
.await
.map_err(Self::error)?;

let encrypt_volume = if encrypt {
Some(EncryptApfsVolume::plan(false, disk, &name, &create_volume).await?)
Some(EncryptApfsVolume::plan(false, disk, &volume_label, &create_volume).await?)
} else {
None
};

let setup_volume_daemon = CreateVolumeService::plan(
NIX_VOLUME_MOUNTD_DEST,
NIX_VOLUME_MOUNTD_NAME,
name.clone(),
volume_label.clone(),
"/nix",
encrypt,
)
Expand All @@ -109,7 +109,7 @@ impl CreateNixVolume {

Ok(Self {
disk: disk.to_path_buf(),
name,
volume_label,
case_sensitive,
encrypt,
create_or_append_synthetic_conf,
Expand All @@ -135,9 +135,9 @@ impl Action for CreateNixVolume {
}
fn tracing_synopsis(&self) -> String {
format!(
"Create an{maybe_encrypted} APFS volume `{name}` for Nix on `{disk}` and add it to `/etc/fstab` mounting on `/nix`",
"Create an{maybe_encrypted} APFS volume `{volume_label}` for Nix on `{disk}` and add it to `/etc/fstab` mounting on `/nix`",
maybe_encrypted = if self.encrypt { " encrypted" } else { "" },
name = self.name,
volume_label = self.volume_label,
disk = self.disk.display(),
)
}
Expand All @@ -147,7 +147,7 @@ impl Action for CreateNixVolume {
tracing::Level::DEBUG,
"create_nix_volume",
disk = tracing::field::display(self.disk.display()),
name = self.name
volume_label = self.volume_label
)
}

Expand Down Expand Up @@ -189,7 +189,7 @@ impl Action for CreateNixVolume {
loop {
let mut command = Command::new("/usr/sbin/diskutil");
command.args(["info", "-plist"]);
command.arg(&self.name);
command.arg(&self.volume_label);
command.stderr(std::process::Stdio::null());
command.stdout(std::process::Stdio::null());
tracing::debug!(%retry_tokens, command = ?command.as_std(), "Checking for Nix Store volume existence");
Expand Down Expand Up @@ -262,7 +262,7 @@ impl Action for CreateNixVolume {
vec![ActionDescription::new(
format!(
"Remove the APFS volume `{}` on `{}`",
self.name,
self.volume_label,
self.disk.display()
),
explanation,
Expand Down

0 comments on commit 68a27d5

Please sign in to comment.