2023-03-17 05:00:14 +02: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
|
|
|
|
unset NIX_STORE_DIR
|
|
|
|
unset NIX_STATE_DIR
|
|
|
|
|
2023-12-11 20:30:40 +02:00
|
|
|
setupStoreDirs
|
2023-03-17 05:00:14 +02:00
|
|
|
|
2023-05-15 22:34:57 +03:00
|
|
|
initLowerStore
|
2023-03-17 05:00:14 +02:00
|
|
|
|
2023-05-15 22:34:57 +03:00
|
|
|
mountOverlayfs
|
2023-05-08 21:47:39 +03:00
|
|
|
|
2023-05-08 23:00:47 +03:00
|
|
|
### Check status
|
2023-03-17 05:00:14 +02:00
|
|
|
|
2023-05-08 23:00:47 +03:00
|
|
|
# Checking for path in lower layer
|
|
|
|
stat $(toRealPath "$storeA/nix/store" "$path")
|
2023-03-17 05:00:14 +02:00
|
|
|
|
2023-05-08 23:00:47 +03:00
|
|
|
# Checking for path in upper layer (should fail)
|
|
|
|
expect 1 stat $(toRealPath "$storeBTop" "$path")
|
2023-03-17 05:00:14 +02:00
|
|
|
|
2023-05-08 23:00:47 +03:00
|
|
|
# Checking for path in overlay store matching lower layer
|
2023-07-20 13:03:14 +03:00
|
|
|
diff $(toRealPath "$storeA/nix/store" "$path") $(toRealPath "$storeBRoot/nix/store" "$path")
|
2023-03-17 05:00:14 +02:00
|
|
|
|
2023-05-10 00:20:58 +03:00
|
|
|
# Checking requisites query agreement
|
|
|
|
[[ \
|
|
|
|
$(nix-store --store $storeA --query --requisites $drvPath) \
|
|
|
|
== \
|
|
|
|
$(nix-store --store $storeB --query --requisites $drvPath) \
|
|
|
|
]]
|
|
|
|
|
|
|
|
# Checking referrers query agreement
|
|
|
|
busyboxStore=$(nix store --store $storeA add-path $busybox)
|
|
|
|
[[ \
|
|
|
|
$(nix-store --store $storeA --query --referrers $busyboxStore) \
|
|
|
|
== \
|
|
|
|
$(nix-store --store $storeB --query --referrers $busyboxStore) \
|
|
|
|
]]
|
|
|
|
|
2023-05-09 23:49:44 +03:00
|
|
|
# Checking derivers query agreement
|
|
|
|
[[ \
|
|
|
|
$(nix-store --store $storeA --query --deriver $path) \
|
|
|
|
== \
|
|
|
|
$(nix-store --store $storeB --query --deriver $path) \
|
|
|
|
]]
|
2023-03-17 05:00:14 +02:00
|
|
|
|
2023-05-09 23:49:44 +03:00
|
|
|
# Checking outputs query agreement
|
2023-05-09 23:42:28 +03:00
|
|
|
[[ \
|
|
|
|
$(nix-store --store $storeA --query --outputs $drvPath) \
|
|
|
|
== \
|
|
|
|
$(nix-store --store $storeB --query --outputs $drvPath) \
|
|
|
|
]]
|
|
|
|
|
2023-05-09 23:49:44 +03:00
|
|
|
# Verifying path in lower layer
|
|
|
|
nix-store --verify-path --store "$storeA" "$path"
|
|
|
|
|
|
|
|
# Verifying path in merged-store
|
|
|
|
nix-store --verify-path --store "$storeB" "$path"
|
|
|
|
|
2023-07-20 12:27:35 +03:00
|
|
|
hashPart=$(echo $path | sed "s^${NIX_STORE_DIR:-/nix/store}/^^" | sed 's/-.*//')
|
2023-05-09 17:40:10 +03:00
|
|
|
|
|
|
|
# Lower store can find from hash part
|
|
|
|
[[ $(nix store --store $storeA path-from-hash-part $hashPart) == $path ]]
|
|
|
|
|
|
|
|
# merged store can find from hash part
|
|
|
|
[[ $(nix store --store $storeB path-from-hash-part $hashPart) == $path ]]
|