-
Notifications
You must be signed in to change notification settings - Fork 130
fix compatibility with Nix 2.32+ show-derivation output #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,17 +240,25 @@ pub async fn build_profile(data: PushProfileData<'_>) -> Result<(), PushProfileE | |
| ) | ||
| .map_err(PushProfileError::ShowDerivationParse)?; | ||
|
|
||
| let &deriver = derivation_info | ||
| let deriver_key = derivation_info | ||
| .keys() | ||
| .next() | ||
| .ok_or(PushProfileError::ShowDerivationEmpty)?; | ||
|
|
||
| let new_deriver = &if data.supports_flakes || data.deploy_data.merged_settings.remote_build.unwrap_or(false) { | ||
| // Nix 2.32+ returns relative paths (without /nix/store/ prefix) in show-derivation output | ||
| // Normalize to always use full store paths | ||
| let deriver = if deriver_key.starts_with("/nix/store/") { | ||
| deriver_key.to_string() | ||
| } else { | ||
| format!("/nix/store/{}", deriver_key) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't allow locations for nix store other than /nix/store. One solution would be to look at $NIX_STORE_DIR env var for location of the store and prepend that, only defaulting to /nix/store. Another would be to utilize the output of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, the command is definitely better, because this can also be configured in nix.conf - https://nix.dev/manual/nix/2.32/command-ref/conf-file.html#conf-store |
||
| }; | ||
|
|
||
| let new_deriver = if data.supports_flakes || data.deploy_data.merged_settings.remote_build.unwrap_or(false) { | ||
| // Since nix 2.15.0 'nix build <path>.drv' will build only the .drv file itself, not the | ||
| // derivation outputs, '^out' is used to refer to outputs explicitly | ||
| deriver.to_owned().to_string() + "^out" | ||
| deriver.clone() + "^out" | ||
| } else { | ||
| deriver.to_owned() | ||
| deriver.clone() | ||
| }; | ||
|
|
||
| let path_info_output = Command::new("nix") | ||
|
|
@@ -260,8 +268,8 @@ pub async fn build_profile(data: PushProfileData<'_>) -> Result<(), PushProfileE | |
| .output().await | ||
| .map_err(PushProfileError::PathInfo)?; | ||
|
|
||
| let deriver = if std::str::from_utf8(&path_info_output.stdout).map(|s| s.trim()) == Ok(deriver) { | ||
| // In this case we're on 2.15.0 or newer, because 'nix path-infonix path-info <...>.drv' | ||
| let deriver = if std::str::from_utf8(&path_info_output.stdout).map(|s| s.trim()) == Ok(deriver.as_str()) { | ||
| // In this case we're on 2.15.0 or newer, because 'nix path-info <...>.drv' | ||
| // returns the same '<...>.drv' path. | ||
| // If 'nix path-info <...>.drv' returns a different path, then we're on pre 2.15.0 nix and | ||
| // derivation build result is already present in the /nix/store. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a check for just '/' would be better. That way people using nix store at different locations will also be able to use this.