Skip to content

Commit

Permalink
fix: nix-store failing on symlinks
Browse files Browse the repository at this point in the history
Resolves #363 by working around NixOS/nix#10247
  • Loading branch information
srid committed Dec 18, 2024
1 parent 2c01547 commit 60922f9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/nix_rs/src/store/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,17 @@ impl NixStoreCmd {
/// Run `nix-store --add` on the give path and return the store path added.
pub async fn nix_store_add(&self, path: &Path) -> Result<StorePath, NixStoreCmdError> {
let mut cmd = self.command();
cmd.arg("--add").arg(path);
cmd.arg("--add");

// nix-store is unable to accept absolute paths if it involves a symlink
// https://github.com/juspay/omnix/issues/363
// To workaround this, we pass the file directly.
if let Some(parent) = path.parent() {
cmd.current_dir(parent);
cmd.arg(path.file_name().unwrap());
} else {
cmd.arg(path);
}

let stdout = run_awaiting_stdout(&mut cmd).await?;
Ok(StorePath::new(PathBuf::from(
Expand Down

0 comments on commit 60922f9

Please sign in to comment.