Skip to content

Commit 9c870f6

Browse files
authored
Merge pull request #346 from XYenon/fix/nix-2-32
fix compatibility with Nix 2.32+ show-derivation output
2 parents 125ae9e + b1b25be commit 9c870f6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/push.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,25 @@ pub async fn build_profile(data: PushProfileData<'_>) -> Result<(), PushProfileE
240240
)
241241
.map_err(PushProfileError::ShowDerivationParse)?;
242242

243-
let &deriver = derivation_info
243+
let deriver_key = derivation_info
244244
.keys()
245245
.next()
246246
.ok_or(PushProfileError::ShowDerivationEmpty)?;
247247

248-
let new_deriver = &if data.supports_flakes || data.deploy_data.merged_settings.remote_build.unwrap_or(false) {
248+
// Nix 2.32+ returns relative paths (without /nix/store/ prefix) in show-derivation output
249+
// Normalize to always use full store paths
250+
let deriver = if deriver_key.starts_with("/nix/store/") {
251+
deriver_key.to_string()
252+
} else {
253+
format!("/nix/store/{}", deriver_key)
254+
};
255+
256+
let new_deriver = if data.supports_flakes || data.deploy_data.merged_settings.remote_build.unwrap_or(false) {
249257
// Since nix 2.15.0 'nix build <path>.drv' will build only the .drv file itself, not the
250258
// derivation outputs, '^out' is used to refer to outputs explicitly
251-
deriver.to_owned().to_string() + "^out"
259+
deriver.clone() + "^out"
252260
} else {
253-
deriver.to_owned()
261+
deriver.clone()
254262
};
255263

256264
let path_info_output = Command::new("nix")
@@ -260,8 +268,8 @@ pub async fn build_profile(data: PushProfileData<'_>) -> Result<(), PushProfileE
260268
.output().await
261269
.map_err(PushProfileError::PathInfo)?;
262270

263-
let deriver = if std::str::from_utf8(&path_info_output.stdout).map(|s| s.trim()) == Ok(deriver) {
264-
// In this case we're on 2.15.0 or newer, because 'nix path-infonix path-info <...>.drv'
271+
let deriver = if std::str::from_utf8(&path_info_output.stdout).map(|s| s.trim()) == Ok(deriver.as_str()) {
272+
// In this case we're on 2.15.0 or newer, because 'nix path-info <...>.drv'
265273
// returns the same '<...>.drv' path.
266274
// If 'nix path-info <...>.drv' returns a different path, then we're on pre 2.15.0 nix and
267275
// derivation build result is already present in the /nix/store.

0 commit comments

Comments
 (0)