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