2023-05-16 03:00:18 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
source common.sh
|
|
|
|
|
2023-07-13 19:39:46 +00:00
|
|
|
# Avoid store dir being inside sandbox build-dir
|
2023-07-20 10:03:14 +00:00
|
|
|
unset NIX_STORE_DIR
|
2023-07-13 19:39:46 +00:00
|
|
|
unset NIX_STATE_DIR
|
|
|
|
|
2023-12-11 18:30:40 +00:00
|
|
|
setupStoreDirs
|
2023-05-16 03:00:18 +00:00
|
|
|
|
|
|
|
initLowerStore
|
|
|
|
|
|
|
|
mountOverlayfs
|
|
|
|
|
|
|
|
### Do a redundant add
|
|
|
|
|
2023-12-11 18:36:53 +00:00
|
|
|
# (Already done in `initLowerStore`, but repeated here for clarity.)
|
2023-12-11 18:48:42 +00:00
|
|
|
pathInLowerStore=$(nix-store --store "$storeA" --add ../dummy)
|
2023-12-11 18:34:09 +00:00
|
|
|
|
2023-12-11 18:36:53 +00:00
|
|
|
# upper layer should not have it
|
2023-12-11 18:48:42 +00:00
|
|
|
expect 1 stat $(toRealPath "$storeBTop/nix/store" "$pathInLowerStore")
|
2023-05-16 03:00:18 +00:00
|
|
|
|
2023-12-11 18:34:09 +00:00
|
|
|
pathFromB=$(nix-store --store "$storeB" --add ../dummy)
|
|
|
|
|
2023-12-11 18:48:42 +00:00
|
|
|
[[ $pathInLowerStore == $pathFromB ]]
|
2023-05-16 03:00:18 +00:00
|
|
|
|
|
|
|
# lower store should have it from before
|
2023-12-11 18:48:42 +00:00
|
|
|
stat $(toRealPath "$storeA/nix/store" "$pathInLowerStore")
|
2023-05-16 03:00:18 +00:00
|
|
|
|
|
|
|
# upper layer should still not have it (no redundant copy)
|
2023-12-11 18:48:42 +00:00
|
|
|
expect 1 stat $(toRealPath "$storeBTop" "$pathInLowerStore")
|