Skip to content

Commit

Permalink
Test using CA derivations with a daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
thufschmitt committed Nov 27, 2020
1 parent 68f23d5 commit 04177fd
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
18 changes: 18 additions & 0 deletions tests/ca/daemon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
source common.sh

# For the post-build hook
export REMOTE_STORE_PATH=$TEST_ROOT/remote_store
export REMOTE_STORE=file://$REMOTE_STORE_PATH

cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
trusted-users = $(whoami)
require-sigs = false
EOF

startDaemon

export NIX_REMOTE_=$NIX_REMOTE

source build.sh
source nix-copy.sh
source substitute.sh
36 changes: 23 additions & 13 deletions tests/ca/nix-copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,29 @@ commonArgs=( \
)

remoteRoot=$TEST_ROOT/store2
chmod -R u+w "$remoteRoot" || true
rm -rf "$remoteRoot"

# Fill the remote cache (by copy-ing only the toplevel derivation outputs to
# make sure that the dependencies are properly registered)
nix copy --to $cacheDir transitivelyDependentCA dependentNonCA dependentFixedOutput "${commonArgs[@]}"
clearStore
clearRemote() {
chmod -R u+w "$remoteRoot" || true
rm -rf "$remoteRoot"
}

backAndForth () {
# Fill the remote cache (by copy-ing only the toplevel derivation outputs to
# make sure that the dependencies are properly registered)
nix copy --to $remoteRoot --no-require-sigs transitivelyDependentCA dependentNonCA dependentFixedOutput "${commonArgs[@]}"
clearStore

# Fetch the otput from the cache
# First one derivation randomly choosen in dependency graph
nix copy --from $remoteRoot --no-require-sigs "${commonArgs[@]}" dependentCA
# Then everything
nix copy --from $remoteRoot --no-require-sigs "${commonArgs[@]}"

# Fetch the otput from the cache
# First one derivation randomly choosen in dependency graph
nix copy --from $cacheDir --no-require-sigs "${commonArgs[@]}" dependentCA
# Then everything
nix copy --from $cacheDir --no-require-sigs "${commonArgs[@]}"
# Ensure that everything is locally present
nix build "${commonArgs[@]}" -j0 --no-link
}

# Ensure that everything is locally present
nix build "${commonArgs[@]}" -j0 --no-link
clearRemote
backAndForth
clearRemote
backAndForth
8 changes: 6 additions & 2 deletions tests/ca/substitute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

source common.sh

export REMOTE_STORE=file://$TEST_ROOT/binary_cache
export REMOTE_STORE_PATH=$TEST_ROOT/remote_store
chmod -R u+w "$REMOTE_STORE_PATH" || true
rm -rf "$REMOTE_STORE_PATH"
export REMOTE_STORE=file://$REMOTE_STORE_PATH

buildDrvs () {
nix --experimental-features 'nix-command ca-derivations ca-references' build --file ./content-addressed.nix -L --no-link "$@"
}

clearStore
# Populate the remote cache
buildDrvs --post-build-hook ../push-to-store.sh
buildDrvs --post-build-hook $PWD/../push-to-store.sh

# Restart the build on an empty store, ensuring that we don't build
clearStore
Expand Down
3 changes: 2 additions & 1 deletion tests/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ nix_tests = \
build.sh \
ca/build.sh \
ca/nix-copy.sh \
ca/substitute.sh
ca/substitute.sh \
ca/daemon.sh
# parallel.sh
# build-remote-content-addressed-fixed.sh \
Expand Down

0 comments on commit 04177fd

Please sign in to comment.