Skip to content

Commit 68a27d5

Browse files
committed
CreateNixVolume: name -> volume_label
1 parent 9fc7084 commit 68a27d5

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/action/macos/create_nix_volume.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub const NIX_VOLUME_MOUNTD_NAME: &str = "org.nixos.darwin-store";
2626
#[serde(tag = "action_name", rename = "create_nix_volume")]
2727
pub struct CreateNixVolume {
2828
disk: PathBuf,
29-
name: String,
29+
volume_label: String,
3030
case_sensitive: bool,
3131
encrypt: bool,
3232
create_or_append_synthetic_conf: StatefulAction<CreateOrInsertIntoFile>,
@@ -45,7 +45,7 @@ impl CreateNixVolume {
4545
#[tracing::instrument(level = "debug", skip_all)]
4646
pub async fn plan(
4747
disk: impl AsRef<Path>,
48-
name: String,
48+
volume_label: String,
4949
case_sensitive: bool,
5050
encrypt: bool,
5151
) -> Result<StatefulAction<Self>, ActionError> {
@@ -63,34 +63,34 @@ impl CreateNixVolume {
6363

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

66-
let create_volume = CreateApfsVolume::plan(disk, name.clone(), case_sensitive)
66+
let create_volume = CreateApfsVolume::plan(disk, volume_label.clone(), case_sensitive)
6767
.await
6868
.map_err(Self::error)?;
6969

7070
let unmount_volume = if create_volume.state == crate::action::ActionState::Completed {
71-
UnmountApfsVolume::plan_skip_if_already_mounted_to_nix(disk, name.clone())
71+
UnmountApfsVolume::plan_skip_if_already_mounted_to_nix(disk, volume_label.clone())
7272
.await
7373
.map_err(Self::error)?
7474
} else {
75-
UnmountApfsVolume::plan(disk, name.clone())
75+
UnmountApfsVolume::plan(disk, volume_label.clone())
7676
.await
7777
.map_err(Self::error)?
7878
};
7979

80-
let create_fstab_entry = CreateFstabEntry::plan(name.clone())
80+
let create_fstab_entry = CreateFstabEntry::plan(volume_label.clone())
8181
.await
8282
.map_err(Self::error)?;
8383

8484
let encrypt_volume = if encrypt {
85-
Some(EncryptApfsVolume::plan(false, disk, &name, &create_volume).await?)
85+
Some(EncryptApfsVolume::plan(false, disk, &volume_label, &create_volume).await?)
8686
} else {
8787
None
8888
};
8989

9090
let setup_volume_daemon = CreateVolumeService::plan(
9191
NIX_VOLUME_MOUNTD_DEST,
9292
NIX_VOLUME_MOUNTD_NAME,
93-
name.clone(),
93+
volume_label.clone(),
9494
"/nix",
9595
encrypt,
9696
)
@@ -109,7 +109,7 @@ impl CreateNixVolume {
109109

110110
Ok(Self {
111111
disk: disk.to_path_buf(),
112-
name,
112+
volume_label,
113113
case_sensitive,
114114
encrypt,
115115
create_or_append_synthetic_conf,
@@ -135,9 +135,9 @@ impl Action for CreateNixVolume {
135135
}
136136
fn tracing_synopsis(&self) -> String {
137137
format!(
138-
"Create an{maybe_encrypted} APFS volume `{name}` for Nix on `{disk}` and add it to `/etc/fstab` mounting on `/nix`",
138+
"Create an{maybe_encrypted} APFS volume `{volume_label}` for Nix on `{disk}` and add it to `/etc/fstab` mounting on `/nix`",
139139
maybe_encrypted = if self.encrypt { " encrypted" } else { "" },
140-
name = self.name,
140+
volume_label = self.volume_label,
141141
disk = self.disk.display(),
142142
)
143143
}
@@ -147,7 +147,7 @@ impl Action for CreateNixVolume {
147147
tracing::Level::DEBUG,
148148
"create_nix_volume",
149149
disk = tracing::field::display(self.disk.display()),
150-
name = self.name
150+
volume_label = self.volume_label
151151
)
152152
}
153153

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

0 commit comments

Comments
 (0)