1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 15:13:55 +02:00

Merge branch 'overlayfs-store' into delete

This commit is contained in:
John Ericson 2023-07-26 12:01:08 -04:00
commit 621bdbdb31
9 changed files with 108 additions and 8 deletions

View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -eu -o pipefail
set -x
source common.sh
# Avoid store dir being inside sandbox build-dir
unset NIX_STORE_DIR
unset NIX_STATE_DIR
storeDirs
initLowerStore
mountOverlayfs
# Add to overlay before lower to ensure file is duplicated
upperPath=$(nix-store --store "$storeB" --add delete-duplicate.sh)
lowerPath=$(nix-store --store "$storeA" --add delete-duplicate.sh)
[[ "$upperPath" = "$lowerPath" ]]
# Check there really are two files with different inodes
upperInode=$(stat -c %i "$storeBRoot/$upperPath")
lowerInode=$(stat -c %i "$storeA/$lowerPath")
[[ "$upperInode" != "$lowerInode" ]]
# Now delete file via the overlay store
nix-store --store "$storeB&remount-hook=$PWD/remount.sh" --delete "$upperPath"
# Check there is no longer a file in upper layer
expect 1 stat "$storeBTop/${upperPath##/nix/store/}"
# Check that overlay file is now the one in lower layer
upperInode=$(stat -c %i "$storeBRoot/$upperPath")
lowerInode=$(stat -c %i "$storeA/$lowerPath")
[[ "$upperInode" = "$lowerInode" ]]

View file

@ -0,0 +1,5 @@
source common.sh
requireEnvironment
setupConfig
execUnshare ./delete-duplicate-inner.sh

View file

@ -5,6 +5,7 @@ overlay-local-store-tests := \
$(d)/bad-uris.sh \
$(d)/add-lower.sh \
$(d)/delete-refs.sh \
$(d)/delete-duplicate.sh \
$(d)/gc.sh \
$(d)/verify.sh \
$(d)/optimise.sh

View file

@ -0,0 +1,2 @@
#!/bin/sh
mount -o remount "$1"