Skip to content

Commit 9600467

Browse files
added changelog file, applied Alexhusazagh suggestions !989
1 parent 09f8947 commit 9600467

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

.changes/989.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "changed",
3+
"description": "add default nix_store value to solve nix-related issues",
4+
"issues": [260]
5+
}

src/docker/shared.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ impl Directories {
270270
let cargo = home::cargo_home()?;
271271
let xargo =
272272
env::var_os("XARGO_HOME").map_or_else(|| home_dir.join(".xargo"), PathBuf::from);
273-
let nix_store = env::var_os("NIX_STORE").map(PathBuf::from);
273+
// NIX_STORE_DIR is an override of NIX_STORE, which is the path in derivations.
274+
let nix_store = env::var_os("NIX_STORE_DIR")
275+
.or_else(|| env::var_os("NIX_STORE"))
276+
.map(PathBuf::from);
274277
let target = &metadata.target_directory;
275278

276279
// create the directories we are going to mount before we mount them,
@@ -292,9 +295,18 @@ impl Directories {
292295
// directories after failed canonicalization into a shared directory.
293296
let cargo = file::canonicalize(&cargo)?;
294297
let xargo = file::canonicalize(&xargo)?;
298+
299+
let default_nix_store = PathBuf::from("/nix/store");
295300
let nix_store = match nix_store {
296-
Some(store) => Some(file::canonicalize(&store)?),
297-
None => Some(PathBuf::from(r"/nix/store")),
301+
Some(store) if store.exists() => {
302+
let path = file::canonicalize(&store)?;
303+
Some(path)
304+
}
305+
Some(store) => {
306+
eyre::bail!("unable to find provided nix-store directory {store:?}");
307+
}
308+
None if cfg!(target_os = "linux") && default_nix_store.exists() => Some(default_nix_store),
309+
None => None,
298310
};
299311

300312
let cargo = mount_finder.find_mount_path(cargo);

0 commit comments

Comments
 (0)