2020-11-09 17:04:43 +02:00
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
# Ensure that binary substitution works properly with ca derivations
|
|
|
|
|
|
|
|
|
|
source common.sh
|
|
|
|
|
|
2024-06-04 00:14:23 +03:00
|
|
|
|
# shellcheck disable=SC1111
|
2021-07-26 07:54:55 +03:00
|
|
|
|
needLocalStore "“--no-require-sigs” can’t be used with the daemon"
|
2020-11-09 17:04:43 +02:00
|
|
|
|
|
2024-06-12 19:42:38 +03:00
|
|
|
|
rm -rf "$TEST_ROOT/binary_cache"
|
2021-03-26 18:10:15 +02:00
|
|
|
|
|
2021-04-22 18:54:02 +03:00
|
|
|
|
export REMOTE_STORE_DIR=$TEST_ROOT/binary_cache
|
|
|
|
|
export REMOTE_STORE=file://$REMOTE_STORE_DIR
|
2020-11-09 17:04:43 +02:00
|
|
|
|
|
|
|
|
|
buildDrvs () {
|
|
|
|
|
nix build --file ./content-addressed.nix -L --no-link "$@"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Populate the remote cache
|
2021-03-26 18:10:15 +02:00
|
|
|
|
clearStore
|
2024-06-04 00:14:23 +03:00
|
|
|
|
nix copy --to "$REMOTE_STORE" --file ./content-addressed.nix
|
2020-11-09 17:04:43 +02:00
|
|
|
|
|
|
|
|
|
# Restart the build on an empty store, ensuring that we don't build
|
|
|
|
|
clearStore
|
2024-06-04 00:14:23 +03:00
|
|
|
|
buildDrvs --substitute --substituters "$REMOTE_STORE" --no-require-sigs -j0 transitivelyDependentCA
|
2021-05-19 15:51:34 +03:00
|
|
|
|
# Check that the thing we’ve just substituted has its realisation stored
|
|
|
|
|
nix realisation info --file ./content-addressed.nix transitivelyDependentCA
|
|
|
|
|
# Check that its dependencies have it too
|
2022-04-20 17:39:47 +03:00
|
|
|
|
nix realisation info --file ./content-addressed.nix dependentCA
|
|
|
|
|
# nix realisation info --file ./content-addressed.nix rootCA --outputs out
|
2020-11-09 17:04:43 +02:00
|
|
|
|
|
Get rid of `.drv` special-casing for store path installables
The release notes document the change in behavior, I don't include it
here so there is no risk to it getting out of sync.
> Motivation
>> Plumbing CLI should be simple
Store derivation installations are intended as "plumbing": very simple
utilities for advanced users and scripts, and not what regular users
interact with. (Similarly, regular Git users will use branch and tag
names not explicit hashes for most things.)
The plumbing CLI should prize simplicity over convenience; that is its
raison d'etre. If the user provides a path, we should treat it the same
way not caring what sort of path it is.
>> Scripting
This is especially important for the scripting use-case. when arbitrary
paths are sent to e.g. `nix copy` and the script author wants consistent
behavior regardless of what those store paths are. Otherwise the script
author needs to be careful to filter out `.drv` ones, and then run `nix
copy` again with those paths and `--derivation`. That is not good!
>> Surprisingly low impact
Only two lines in the tests need changing, showing that the impact of
this is pretty light.
Many command, like `nix log` will continue to work with just the
derivation passed as before. This because we used to:
- Special case the drv path and replace it with it's outputs (what this
gets rid of).
- Turn those output path *back* into the original drv path.
Now we just skip that entire round trip!
> Context
Issue #7261 lays out a broader vision for getting rid of `--derivation`,
and has this as one of its dependencies. But we can do this with or
without that.
`Installable::toDerivations` is changed to handle the case of a
`DerivedPath::Opaque` ending in `.drv`, which is new: it simply doesn't
need to do any extra work in that case. On this basis, commands like
`nix {show-derivation,log} /nix/store/...-foo.drv` still work as before,
as described above.
When testing older daemons, the post-build-hook will be run against the
old CLI, so we need the old version of the post-build-hook to support
that use-case.
Co-authored-by: Travis A. Everett <travis.a.everett@gmail.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2022-12-16 05:44:14 +02:00
|
|
|
|
if isDaemonNewer "2.13"; then
|
|
|
|
|
pushToStore="../push-to-store.sh"
|
|
|
|
|
else
|
|
|
|
|
pushToStore="../push-to-store-old.sh"
|
|
|
|
|
fi
|
|
|
|
|
|
2021-04-22 18:54:02 +03:00
|
|
|
|
# Same thing, but
|
|
|
|
|
# 1. With non-ca derivations
|
|
|
|
|
# 2. Erasing the realisations on the remote store
|
|
|
|
|
#
|
|
|
|
|
# Even in that case, realising the derivations should still produce the right
|
|
|
|
|
# realisations on the local store
|
|
|
|
|
#
|
|
|
|
|
# Regression test for #4725
|
|
|
|
|
clearStore
|
Get rid of `.drv` special-casing for store path installables
The release notes document the change in behavior, I don't include it
here so there is no risk to it getting out of sync.
> Motivation
>> Plumbing CLI should be simple
Store derivation installations are intended as "plumbing": very simple
utilities for advanced users and scripts, and not what regular users
interact with. (Similarly, regular Git users will use branch and tag
names not explicit hashes for most things.)
The plumbing CLI should prize simplicity over convenience; that is its
raison d'etre. If the user provides a path, we should treat it the same
way not caring what sort of path it is.
>> Scripting
This is especially important for the scripting use-case. when arbitrary
paths are sent to e.g. `nix copy` and the script author wants consistent
behavior regardless of what those store paths are. Otherwise the script
author needs to be careful to filter out `.drv` ones, and then run `nix
copy` again with those paths and `--derivation`. That is not good!
>> Surprisingly low impact
Only two lines in the tests need changing, showing that the impact of
this is pretty light.
Many command, like `nix log` will continue to work with just the
derivation passed as before. This because we used to:
- Special case the drv path and replace it with it's outputs (what this
gets rid of).
- Turn those output path *back* into the original drv path.
Now we just skip that entire round trip!
> Context
Issue #7261 lays out a broader vision for getting rid of `--derivation`,
and has this as one of its dependencies. But we can do this with or
without that.
`Installable::toDerivations` is changed to handle the case of a
`DerivedPath::Opaque` ending in `.drv`, which is new: it simply doesn't
need to do any extra work in that case. On this basis, commands like
`nix {show-derivation,log} /nix/store/...-foo.drv` still work as before,
as described above.
When testing older daemons, the post-build-hook will be run against the
old CLI, so we need the old version of the post-build-hook to support
that use-case.
Co-authored-by: Travis A. Everett <travis.a.everett@gmail.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2022-12-16 05:44:14 +02:00
|
|
|
|
nix build --file ../simple.nix -L --no-link --post-build-hook "$pushToStore"
|
2021-04-22 18:54:02 +03:00
|
|
|
|
clearStore
|
|
|
|
|
rm -r "$REMOTE_STORE_DIR/realisations"
|
|
|
|
|
nix build --file ../simple.nix -L --no-link --substitute --substituters "$REMOTE_STORE" --no-require-sigs -j0
|
2021-04-23 10:34:16 +03:00
|
|
|
|
# There's no easy way to check whether a realisation is present on the local
|
|
|
|
|
# store − short of manually querying the db, but the build environment doesn't
|
|
|
|
|
# have the sqlite binary − so we instead push things again, and check that the
|
|
|
|
|
# realisations have correctly been pushed to the remote store
|
|
|
|
|
nix copy --to "$REMOTE_STORE" --file ../simple.nix
|
|
|
|
|
if [[ -z "$(ls "$REMOTE_STORE_DIR/realisations")" ]]; then
|
2021-04-22 18:54:02 +03:00
|
|
|
|
echo "Realisations not rebuilt"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2021-05-06 17:45:09 +03:00
|
|
|
|
|
|
|
|
|
# Test the local realisation disk cache
|
Get rid of `.drv` special-casing for store path installables
The release notes document the change in behavior, I don't include it
here so there is no risk to it getting out of sync.
> Motivation
>> Plumbing CLI should be simple
Store derivation installations are intended as "plumbing": very simple
utilities for advanced users and scripts, and not what regular users
interact with. (Similarly, regular Git users will use branch and tag
names not explicit hashes for most things.)
The plumbing CLI should prize simplicity over convenience; that is its
raison d'etre. If the user provides a path, we should treat it the same
way not caring what sort of path it is.
>> Scripting
This is especially important for the scripting use-case. when arbitrary
paths are sent to e.g. `nix copy` and the script author wants consistent
behavior regardless of what those store paths are. Otherwise the script
author needs to be careful to filter out `.drv` ones, and then run `nix
copy` again with those paths and `--derivation`. That is not good!
>> Surprisingly low impact
Only two lines in the tests need changing, showing that the impact of
this is pretty light.
Many command, like `nix log` will continue to work with just the
derivation passed as before. This because we used to:
- Special case the drv path and replace it with it's outputs (what this
gets rid of).
- Turn those output path *back* into the original drv path.
Now we just skip that entire round trip!
> Context
Issue #7261 lays out a broader vision for getting rid of `--derivation`,
and has this as one of its dependencies. But we can do this with or
without that.
`Installable::toDerivations` is changed to handle the case of a
`DerivedPath::Opaque` ending in `.drv`, which is new: it simply doesn't
need to do any extra work in that case. On this basis, commands like
`nix {show-derivation,log} /nix/store/...-foo.drv` still work as before,
as described above.
When testing older daemons, the post-build-hook will be run against the
old CLI, so we need the old version of the post-build-hook to support
that use-case.
Co-authored-by: Travis A. Everett <travis.a.everett@gmail.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2022-12-16 05:44:14 +02:00
|
|
|
|
buildDrvs --post-build-hook "$pushToStore"
|
2021-05-06 17:45:09 +03:00
|
|
|
|
clearStore
|
|
|
|
|
# Add the realisations of rootCA to the cachecache
|
|
|
|
|
clearCacheCache
|
|
|
|
|
export _NIX_FORCE_HTTP=1
|
2024-06-04 00:14:23 +03:00
|
|
|
|
buildDrvs --substitute --substituters "$REMOTE_STORE" --no-require-sigs -j0
|
2021-05-06 17:45:09 +03:00
|
|
|
|
# Try rebuilding, but remove the realisations from the remote cache to force
|
|
|
|
|
# using the cachecache
|
|
|
|
|
clearStore
|
2024-06-04 00:14:23 +03:00
|
|
|
|
rm "$REMOTE_STORE_DIR"/realisations/*
|
|
|
|
|
buildDrvs --substitute --substituters "$REMOTE_STORE" --no-require-sigs -j0
|