mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
No longer copy functional tests to the build dir
This should make `_NIX_TEST_ACCEPT=1` work again, fixing #11369. Progress on #2503
This commit is contained in:
parent
55fe4ee4f3
commit
9d2ed0a7d3
@ -9,13 +9,21 @@ test_name=$(echo -n "${test?must be defined by caller (test runner)}" | sed \
|
|||||||
-e "s|\.sh$||" \
|
-e "s|\.sh$||" \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Layer violation, but I am not inclined to care too much, as this code
|
||||||
|
# is about to be deleted.
|
||||||
|
src_dir=$(realpath tests/functional)
|
||||||
|
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
TESTS_ENVIRONMENT=(
|
TESTS_ENVIRONMENT=(
|
||||||
"TEST_NAME=$test_name"
|
"TEST_NAME=$test_name"
|
||||||
'NIX_REMOTE='
|
'NIX_REMOTE='
|
||||||
'PS4=+(${BASH_SOURCE[0]-$0}:$LINENO) '
|
'PS4=+(${BASH_SOURCE[0]-$0}:$LINENO) '
|
||||||
|
"_NIX_TEST_SOURCE_DIR=${src_dir}"
|
||||||
|
"_NIX_TEST_BUILD_DIR=${src_dir}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
unset src_dir
|
||||||
|
|
||||||
read -r -a bash <<< "${BASH:-/usr/bin/env bash}"
|
read -r -a bash <<< "${BASH:-/usr/bin/env bash}"
|
||||||
|
|
||||||
run () {
|
run () {
|
||||||
|
@ -238,7 +238,7 @@ clearCache
|
|||||||
# preserve quotes variables in the single-quoted string
|
# preserve quotes variables in the single-quoted string
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
outPath=$(nix-build --no-out-link -E '
|
outPath=$(nix-build --no-out-link -E '
|
||||||
with import ./config.nix;
|
with import '"${config_nix}"';
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "nar-listing";
|
name = "nar-listing";
|
||||||
buildCommand = "mkdir $out; echo foo > $out/bar; ln -s xyzzy $out/link";
|
buildCommand = "mkdir $out; echo foo > $out/bar; ln -s xyzzy $out/link";
|
||||||
@ -258,7 +258,7 @@ clearCache
|
|||||||
# preserve quotes variables in the single-quoted string
|
# preserve quotes variables in the single-quoted string
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
outPath=$(nix-build --no-out-link -E '
|
outPath=$(nix-build --no-out-link -E '
|
||||||
with import ./config.nix;
|
with import '"${config_nix}"';
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "debug-info";
|
name = "debug-info";
|
||||||
buildCommand = "mkdir -p $out/lib/debug/.build-id/02; echo foo > $out/lib/debug/.build-id/02/623eda209c26a59b1a8638ff7752f6b945c26b.debug";
|
buildCommand = "mkdir -p $out/lib/debug/.build-id/02; echo foo > $out/lib/debug/.build-id/02/623eda209c26a59b1a8638ff7752f6b945c26b.debug";
|
||||||
@ -276,7 +276,7 @@ diff -u \
|
|||||||
# preserve quotes variables in the single-quoted string
|
# preserve quotes variables in the single-quoted string
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
expr='
|
expr='
|
||||||
with import ./config.nix;
|
with import '"${config_nix}"';
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "multi-output";
|
name = "multi-output";
|
||||||
buildCommand = "mkdir -p $out; echo foo > $doc; echo $doc > $out/docref";
|
buildCommand = "mkdir -p $out; echo foo > $doc; echo $doc > $out/docref";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ busybox }:
|
{ busybox }:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ busybox, contentAddressed ? false }:
|
{ busybox, contentAddressed ? false }:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/ca/config.nix";
|
||||||
|
|
||||||
let mkCADerivation = args: mkDerivation ({
|
let mkCADerivation = args: mkDerivation ({
|
||||||
__contentAddressed = true;
|
__contentAddressed = true;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source ./common.sh
|
source common.sh
|
||||||
|
|
||||||
requireDaemonNewerThan "2.4pre20210625"
|
requireDaemonNewerThan "2.4pre20210625"
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
@ -29,5 +29,5 @@ suites += {
|
|||||||
'substitute.sh',
|
'substitute.sh',
|
||||||
'why-depends.sh',
|
'why-depends.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_build_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
FLAKE_PATH=path:$PWD
|
flakeDir="$TEST_HOME/flake"
|
||||||
|
mkdir -p "${flakeDir}"
|
||||||
|
cp flake.nix "${_NIX_TEST_BUILD_DIR}/ca/config.nix" content-addressed.nix "${flakeDir}"
|
||||||
|
|
||||||
nix run --no-write-lock-file "$FLAKE_PATH#runnable"
|
# `config.nix` cannot be gotten via build dir / env var (runs afoul pure eval). Instead get from flake.
|
||||||
|
removeBuildDirRef "$flakeDir"/*.nix
|
||||||
|
|
||||||
|
nix run --no-write-lock-file "path:${flakeDir}#runnable"
|
||||||
|
@ -5,4 +5,3 @@ source common.sh
|
|||||||
CONTENT_ADDRESSED=true
|
CONTENT_ADDRESSED=true
|
||||||
cd ..
|
cd ..
|
||||||
source ./nix-shell.sh
|
source ./nix-shell.sh
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/ca/config.nix";
|
||||||
|
|
||||||
let mkCADerivation = args: mkDerivation ({
|
let mkCADerivation = args: mkDerivation ({
|
||||||
__contentAddressed = true;
|
__contentAddressed = true;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# build it at once.
|
# build it at once.
|
||||||
|
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/ca/config.nix";
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "simple";
|
name = "simple";
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
dep1 = mkDerivation {
|
dep1 = mkDerivation {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{checkBuildId ? 0}:
|
{checkBuildId ? 0}:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
{
|
{
|
||||||
nondeterministic = mkDerivation {
|
nondeterministic = mkDerivation {
|
||||||
|
@ -37,7 +37,10 @@ if canUseSandbox; then
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cp simple.nix shell.nix simple.builder.sh config.nix "$flakeDir/"
|
cp simple.nix shell.nix simple.builder.sh "${config_nix}" "$flakeDir/"
|
||||||
|
|
||||||
|
# `config.nix` cannot be gotten via build dir / env var (runs afoul pure eval). Instead get from flake.
|
||||||
|
removeBuildDirRef "$flakeDir"/*.nix
|
||||||
|
|
||||||
TODO_NixOS
|
TODO_NixOS
|
||||||
|
|
||||||
|
@ -343,6 +343,15 @@ count() {
|
|||||||
echo $#
|
echo $#
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Sometimes, e.g. due to pure eval, restricted eval, or sandboxing, we
|
||||||
|
# cannot look up `config.nix` in the build dir, and have to instead get
|
||||||
|
# it from the current directory. (In this case, the current directly
|
||||||
|
# will be somewhere in `$TEST_ROOT`.)
|
||||||
|
removeBuildDirRef() {
|
||||||
|
# shellcheck disable=SC2016 # The ${} in this is Nix, not shell
|
||||||
|
sed -i -e 's,"${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/[^ ]*config.nix",./config.nix,' "$@"
|
||||||
|
}
|
||||||
|
|
||||||
trap onError ERR
|
trap onError ERR
|
||||||
|
|
||||||
fi # COMMON_FUNCTIONS_SH_SOURCED
|
fi # COMMON_FUNCTIONS_SH_SOURCED
|
||||||
|
@ -8,11 +8,10 @@ COMMON_PATHS_SH_SOURCED=1
|
|||||||
|
|
||||||
commonDir="$(readlink -f "$(dirname "${BASH_SOURCE[0]-$0}")")"
|
commonDir="$(readlink -f "$(dirname "${BASH_SOURCE[0]-$0}")")"
|
||||||
|
|
||||||
# Since these are generated files
|
# Just for `isTestOnNixOS`
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source "$commonDir/functions.sh"
|
source "$commonDir/functions.sh"
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source "$commonDir/subst-vars.sh"
|
source "${_NIX_TEST_BUILD_DIR}/common/subst-vars.sh"
|
||||||
# Make sure shellcheck knows this will be defined by the above generated snippet
|
# Make sure shellcheck knows this will be defined by the above generated snippet
|
||||||
: "${bash?}" "${bindir?}"
|
: "${bash?}" "${bindir?}"
|
||||||
|
|
||||||
|
@ -6,11 +6,14 @@ if [[ -z "${COMMON_VARS_SH_SOURCED-}" ]]; then
|
|||||||
|
|
||||||
COMMON_VARS_SH_SOURCED=1
|
COMMON_VARS_SH_SOURCED=1
|
||||||
|
|
||||||
|
_NIX_TEST_SOURCE_DIR=$(realpath "${_NIX_TEST_SOURCE_DIR}")
|
||||||
|
_NIX_TEST_BUILD_DIR=$(realpath "${_NIX_TEST_BUILD_DIR}")
|
||||||
|
|
||||||
commonDir="$(readlink -f "$(dirname "${BASH_SOURCE[0]-$0}")")"
|
commonDir="$(readlink -f "$(dirname "${BASH_SOURCE[0]-$0}")")"
|
||||||
|
|
||||||
# Since this is a generated file
|
# Since this is a generated file
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source "$commonDir/subst-vars.sh"
|
source "${_NIX_TEST_BUILD_DIR}/common/subst-vars.sh"
|
||||||
# Make sure shellcheck knows all these will be defined by the above generated snippet
|
# Make sure shellcheck knows all these will be defined by the above generated snippet
|
||||||
: "${bindir?} ${coreutils?} ${dot?} ${SHELL?} ${busybox?} ${version?} ${system?}"
|
: "${bindir?} ${coreutils?} ${dot?} ${SHELL?} ${busybox?} ${version?} ${system?}"
|
||||||
export coreutils dot busybox version system
|
export coreutils dot busybox version system
|
||||||
@ -69,4 +72,9 @@ if [[ $(uname) == Linux ]] && [[ -L /proc/self/ns/user ]] && unshare --user true
|
|||||||
_canUseSandbox=1
|
_canUseSandbox=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Very common, shorthand helps
|
||||||
|
# Used in other files
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
config_nix="${_NIX_TEST_BUILD_DIR}/config.nix"
|
||||||
|
|
||||||
fi # COMMON_VARS_SH_SOURCED
|
fi # COMMON_VARS_SH_SOURCED
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ hashInvalidator ? "" }:
|
{ hashInvalidator ? "" }:
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|
||||||
|
@ -15,5 +15,5 @@ suites += {
|
|||||||
'dep-built-drv.sh',
|
'dep-built-drv.sh',
|
||||||
'old-daemon-error-hack.sh',
|
'old-daemon-error-hack.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_build_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/dyn-drv/config.nix";
|
||||||
|
|
||||||
# A simple content-addressed derivation.
|
# A simple content-addressed derivation.
|
||||||
# The derivation can be arbitrarily modified by passing a different `seed`,
|
# The derivation can be arbitrarily modified by passing a different `seed`,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/dyn-drv/config.nix";
|
||||||
|
|
||||||
let innerName = "foo"; in
|
let innerName = "foo"; in
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/dyn-drv/config.nix";
|
||||||
|
|
||||||
# A simple content-addressed derivation.
|
# A simple content-addressed derivation.
|
||||||
# The derivation can be arbitrarily modified by passing a different `seed`,
|
# The derivation can be arbitrarily modified by passing a different `seed`,
|
||||||
|
@ -45,7 +45,7 @@ printf 123 > "$TEST_ROOT/xyzzy/default.nix"
|
|||||||
[[ $(nix eval --impure --expr "import $TEST_ROOT/foo/bar") = 123 ]]
|
[[ $(nix eval --impure --expr "import $TEST_ROOT/foo/bar") = 123 ]]
|
||||||
|
|
||||||
# Test --arg-from-file.
|
# Test --arg-from-file.
|
||||||
[[ "$(nix eval --raw --arg-from-file foo config.nix --expr '{ foo }: { inherit foo; }' foo)" = "$(cat config.nix)" ]]
|
[[ "$(nix eval --raw --arg-from-file foo "${config_nix}" --expr '{ foo }: { inherit foo; }' foo)" = "$(cat "${config_nix}")" ]]
|
||||||
|
|
||||||
# Check that special(-ish) files are drained.
|
# Check that special(-ish) files are drained.
|
||||||
if [[ -e /proc/version ]]; then
|
if [[ -e /proc/version ]]; then
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ destFile, seed }:
|
{ destFile, seed }:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "simple";
|
name = "simple";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{ busybox }:
|
{ busybox }:
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
let
|
let
|
||||||
|
|
||||||
mkDerivation = args:
|
mkDerivation = args:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "filter";
|
name = "filter";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ cat > "$flake1Dir"/flake.nix <<EOF
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cp ../simple.nix ../simple.builder.sh ../config.nix "$flake1Dir/"
|
cp ../simple.nix ../simple.builder.sh "${config_nix}" "$flake1Dir/"
|
||||||
|
|
||||||
echo bar > "$flake1Dir/foo"
|
echo bar > "$flake1Dir/foo"
|
||||||
|
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
cp ../simple.nix ../simple.builder.sh ../config.nix "$TEST_HOME"
|
cp ../simple.nix ../simple.builder.sh "${config_nix}" "$TEST_HOME"
|
||||||
|
|
||||||
|
# `config.nix` cannot be gotten via build dir / env var (runs afoul pure eval). Instead get from flake.
|
||||||
|
removeBuildDirRef "$TEST_HOME"/*.nix
|
||||||
|
|
||||||
cd "$TEST_HOME"
|
cd "$TEST_HOME"
|
||||||
|
|
||||||
|
@ -34,7 +34,10 @@ writeSimpleFlake() {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cp ../simple.nix ../shell.nix ../simple.builder.sh ../config.nix "$flakeDir/"
|
cp ../simple.nix ../shell.nix ../simple.builder.sh "${config_nix}" "$flakeDir/"
|
||||||
|
|
||||||
|
# `config.nix` cannot be gotten via build dir / env var (runs afoul pure eval). Instead get from flake.
|
||||||
|
removeBuildDirRef "$flakeDir"/*.nix
|
||||||
}
|
}
|
||||||
|
|
||||||
createSimpleGitFlake() {
|
createSimpleGitFlake() {
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
cp ../simple.nix ../simple.builder.sh ../config.nix $TEST_HOME
|
cp ../simple.nix ../simple.builder.sh "${config_nix}" $TEST_HOME
|
||||||
|
removeBuildDirRef "$TEST_HOME/simple.nix"
|
||||||
|
|
||||||
cd $TEST_HOME
|
cd $TEST_HOME
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ clearStore
|
|||||||
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
|
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
|
||||||
|
|
||||||
# Create flake under test.
|
# Create flake under test.
|
||||||
cp ../shell-hello.nix ../config.nix $TEST_HOME/
|
cp ../shell-hello.nix "${config_nix}" $TEST_HOME/
|
||||||
cat <<EOF >$TEST_HOME/flake.nix
|
cat <<EOF >$TEST_HOME/flake.nix
|
||||||
{
|
{
|
||||||
inputs.nixpkgs.url = "$TEST_HOME/nixpkgs";
|
inputs.nixpkgs.url = "$TEST_HOME/nixpkgs";
|
||||||
@ -25,7 +25,11 @@ EOF
|
|||||||
|
|
||||||
# Create fake nixpkgs flake.
|
# Create fake nixpkgs flake.
|
||||||
mkdir -p $TEST_HOME/nixpkgs
|
mkdir -p $TEST_HOME/nixpkgs
|
||||||
cp ../config.nix ../shell.nix $TEST_HOME/nixpkgs
|
cp "${config_nix}" ../shell.nix $TEST_HOME/nixpkgs
|
||||||
|
|
||||||
|
# `config.nix` cannot be gotten via build dir / env var (runs afoul pure eval). Instead get from flake.
|
||||||
|
removeBuildDirRef "$TEST_HOME/nixpkgs"/*.nix
|
||||||
|
|
||||||
cat <<EOF >$TEST_HOME/nixpkgs/flake.nix
|
cat <<EOF >$TEST_HOME/nixpkgs/flake.nix
|
||||||
{
|
{
|
||||||
outputs = {self}: {
|
outputs = {self}: {
|
||||||
|
@ -7,7 +7,7 @@ requireGit
|
|||||||
flake1Dir="$TEST_ROOT/eval-cache-flake"
|
flake1Dir="$TEST_ROOT/eval-cache-flake"
|
||||||
|
|
||||||
createGitRepo "$flake1Dir" ""
|
createGitRepo "$flake1Dir" ""
|
||||||
cp ../simple.nix ../simple.builder.sh ../config.nix "$flake1Dir/"
|
cp ../simple.nix ../simple.builder.sh "${config_nix}" "$flake1Dir/"
|
||||||
git -C "$flake1Dir" add simple.nix simple.builder.sh config.nix
|
git -C "$flake1Dir" add simple.nix simple.builder.sh config.nix
|
||||||
git -C "$flake1Dir" commit -m "config.nix"
|
git -C "$flake1Dir" commit -m "config.nix"
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ cat > "$flake3Dir/flake.nix" <<EOF
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cp ../config.nix "$flake3Dir"
|
cp "${config_nix}" "$flake3Dir"
|
||||||
|
|
||||||
git -C "$flake3Dir" add flake.nix config.nix
|
git -C "$flake3Dir" add flake.nix config.nix
|
||||||
git -C "$flake3Dir" commit -m 'Add nonFlakeInputs'
|
git -C "$flake3Dir" commit -m 'Add nonFlakeInputs'
|
||||||
|
@ -25,5 +25,5 @@ suites += {
|
|||||||
'show.sh',
|
'show.sh',
|
||||||
'dubious-query.sh',
|
'dubious-query.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_build_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,10 @@ TODO_NixOS
|
|||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
|
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
|
||||||
cp ../shell-hello.nix ../config.nix $TEST_HOME
|
|
||||||
|
cp ../shell-hello.nix "${config_nix}" $TEST_HOME
|
||||||
|
# `config.nix` cannot be gotten via build dir / env var (runs afoul pure eval). Instead get from flake.
|
||||||
|
removeBuildDirRef "$TEST_HOME"/*.nix
|
||||||
cd $TEST_HOME
|
cd $TEST_HOME
|
||||||
|
|
||||||
cat <<EOF > flake.nix
|
cat <<EOF > flake.nix
|
||||||
|
@ -7,7 +7,7 @@ TODO_NixOS # Provide a `shell` variable. Try not to `export` it, perhaps.
|
|||||||
clearStoreIfPossible
|
clearStoreIfPossible
|
||||||
rm -rf "$TEST_HOME"/.cache "$TEST_HOME"/.config "$TEST_HOME"/.local
|
rm -rf "$TEST_HOME"/.cache "$TEST_HOME"/.config "$TEST_HOME"/.local
|
||||||
|
|
||||||
cp ./simple.nix ./simple.builder.sh ./fmt.simple.sh ./config.nix "$TEST_HOME"
|
cp ./simple.nix ./simple.builder.sh ./fmt.simple.sh "${config_nix}" "$TEST_HOME"
|
||||||
|
|
||||||
cd "$TEST_HOME"
|
cd "$TEST_HOME"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
rec {
|
rec {
|
||||||
x1 = mkDerivation {
|
x1 = mkDerivation {
|
||||||
name = "x1";
|
name = "x1";
|
||||||
|
@ -23,7 +23,7 @@ fifoLock=$TEST_ROOT/fifoLock
|
|||||||
mkfifo "$fifoLock"
|
mkfifo "$fifoLock"
|
||||||
|
|
||||||
expr=$(cat <<EOF
|
expr=$(cat <<EOF
|
||||||
with import ./config.nix; mkDerivation {
|
with import ${config_nix}; mkDerivation {
|
||||||
name = "gc-A";
|
name = "gc-A";
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
set -x
|
set -x
|
||||||
@ -51,7 +51,7 @@ EOF
|
|||||||
)
|
)
|
||||||
|
|
||||||
expr2=$(cat <<EOF
|
expr2=$(cat <<EOF
|
||||||
with import ./config.nix; mkDerivation {
|
with import ${config_nix}; mkDerivation {
|
||||||
name = "gc-B";
|
name = "gc-B";
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
set -x
|
set -x
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
{ lockFifo ? null }:
|
{ lockFifo ? null }:
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ pid2=$!
|
|||||||
|
|
||||||
# Start a build. This should not be blocked by the GC in progress.
|
# Start a build. This should not be blocked by the GC in progress.
|
||||||
outPath=$(nix-build --max-silent-time 60 -o "$TEST_ROOT/result" -E "
|
outPath=$(nix-build --max-silent-time 60 -o "$TEST_ROOT/result" -E "
|
||||||
with import ./config.nix;
|
with import ${config_nix};
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = \"non-blocking\";
|
name = \"non-blocking\";
|
||||||
buildCommand = \"set -x; test -e $running; mkdir \$out; echo > $fifo2\";
|
buildCommand = \"set -x; test -e $running; mkdir \$out; echo > $fifo2\";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "gc-runtime";
|
name = "gc-runtime";
|
||||||
|
@ -4,5 +4,5 @@ suites += {
|
|||||||
'tests': [
|
'tests': [
|
||||||
'simple.sh',
|
'simple.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_build_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
, withFinalRefs ? false
|
, withFinalRefs ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
let
|
let
|
||||||
contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1";
|
contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
import (
|
import (
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "foo";
|
name = "foo";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
bar = mkDerivation {
|
bar = mkDerivation {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ var, value }:
|
{ var, value }:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "test";
|
name = "test";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ mode }:
|
{ mode }:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
mkDerivation (
|
mkDerivation (
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ grepQuiet 'may not be deterministic' $TEST_ROOT/log
|
|||||||
|
|
||||||
# Test that sandboxed builds cannot write to /etc easily
|
# Test that sandboxed builds cannot write to /etc easily
|
||||||
# `100` means build failure without extra info, see doc/manual/source/command-ref/status-build-failure.md
|
# `100` means build failure without extra info, see doc/manual/source/command-ref/status-build-failure.md
|
||||||
expectStderr 100 nix-sandbox-build -E 'with import ./config.nix; mkDerivation { name = "etc-write"; buildCommand = "echo > /etc/test"; }' |
|
expectStderr 100 nix-sandbox-build -E 'with import '"${config_nix}"'; mkDerivation { name = "etc-write"; buildCommand = "echo > /etc/test"; }' |
|
||||||
grepQuiet "/etc/test: Permission denied"
|
grepQuiet "/etc/test: Permission denied"
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,5 +14,5 @@ suites += {
|
|||||||
'optimise.sh',
|
'optimise.sh',
|
||||||
'stale-file-handle.sh',
|
'stale-file-handle.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_build_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ nix-build dependencies.nix --no-out-link --compress-build-log
|
|||||||
builder="$(realpath "$(mktemp)")"
|
builder="$(realpath "$(mktemp)")"
|
||||||
echo -e "#!/bin/sh\nmkdir \$out" > "$builder"
|
echo -e "#!/bin/sh\nmkdir \$out" > "$builder"
|
||||||
outp="$(nix-build -E \
|
outp="$(nix-build -E \
|
||||||
'with import ./config.nix; mkDerivation { name = "fnord"; builder = '"$builder"'; }' \
|
'with import '"${config_nix}"'; mkDerivation { name = "fnord"; builder = '"$builder"'; }' \
|
||||||
--out-link "$(mktemp -d)/result")"
|
--out-link "$(mktemp -d)/result")"
|
||||||
|
|
||||||
test -d "$outp"
|
test -d "$outp"
|
||||||
|
@ -14,27 +14,6 @@ project('nix-functional-tests', 'cpp',
|
|||||||
|
|
||||||
fs = import('fs')
|
fs = import('fs')
|
||||||
|
|
||||||
# Need to combine source and build trees
|
|
||||||
run_command(
|
|
||||||
'rsync',
|
|
||||||
'-a',
|
|
||||||
'--copy-unsafe-links',
|
|
||||||
meson.current_source_dir() / '',
|
|
||||||
meson.current_build_dir() / '',
|
|
||||||
)
|
|
||||||
# This current-source-escaping relative is no good because we don't know
|
|
||||||
# where the build directory will be, therefore we fix it up. Once the
|
|
||||||
# Make build system is gone, we should think about doing this better.
|
|
||||||
scripts_dir = fs.relative_to(
|
|
||||||
meson.current_source_dir() / '..' / '..' / 'scripts',
|
|
||||||
meson.current_build_dir(),
|
|
||||||
)
|
|
||||||
run_command(
|
|
||||||
'sed',
|
|
||||||
'-i', meson.current_build_dir() / 'bash-profile.sh',
|
|
||||||
'-e', 's^../../scripts^@0@^'.format(scripts_dir),
|
|
||||||
)
|
|
||||||
|
|
||||||
nix = find_program('nix')
|
nix = find_program('nix')
|
||||||
bash = find_program('bash', native : true)
|
bash = find_program('bash', native : true)
|
||||||
busybox = find_program('busybox', native : true, required : false)
|
busybox = find_program('busybox', native : true, required : false)
|
||||||
@ -185,7 +164,7 @@ suites = [
|
|||||||
'extra-sandbox-profile.sh',
|
'extra-sandbox-profile.sh',
|
||||||
'help.sh',
|
'help.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_build_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -200,7 +179,7 @@ if nix_store.found()
|
|||||||
'tests': [
|
'tests': [
|
||||||
'test-libstoreconsumer.sh',
|
'test-libstoreconsumer.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_build_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
}
|
}
|
||||||
|
|
||||||
endif
|
endif
|
||||||
@ -217,7 +196,7 @@ if nix_expr.found() and get_option('default_library') != 'static'
|
|||||||
'tests': [
|
'tests': [
|
||||||
'plugins.sh',
|
'plugins.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_build_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
}
|
}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -228,14 +207,12 @@ subdir('git-hashing')
|
|||||||
subdir('local-overlay-store')
|
subdir('local-overlay-store')
|
||||||
|
|
||||||
foreach suite : suites
|
foreach suite : suites
|
||||||
|
workdir = suite['workdir']
|
||||||
|
suite_name = suite['name']
|
||||||
foreach script : suite['tests']
|
foreach script : suite['tests']
|
||||||
workdir = suite['workdir']
|
|
||||||
prefix = fs.relative_to(workdir, meson.project_build_root())
|
|
||||||
|
|
||||||
script = script
|
|
||||||
# Turns, e.g., `tests/functional/flakes/show.sh` into a Meson test target called
|
# Turns, e.g., `tests/functional/flakes/show.sh` into a Meson test target called
|
||||||
# `functional-flakes-show`.
|
# `functional-flakes-show`.
|
||||||
name = fs.replace_suffix(prefix / script, '')
|
name = fs.replace_suffix(script, '')
|
||||||
|
|
||||||
test(
|
test(
|
||||||
name,
|
name,
|
||||||
@ -247,9 +224,11 @@ foreach suite : suites
|
|||||||
'-o', 'pipefail',
|
'-o', 'pipefail',
|
||||||
script,
|
script,
|
||||||
],
|
],
|
||||||
suite : suite['name'],
|
suite : suite_name,
|
||||||
env : {
|
env : {
|
||||||
'TEST_NAME': name,
|
'_NIX_TEST_SOURCE_DIR': meson.current_source_dir(),
|
||||||
|
'_NIX_TEST_BUILD_DIR': meson.current_build_dir(),
|
||||||
|
'TEST_NAME': suite_name / name,
|
||||||
'NIX_REMOTE': '',
|
'NIX_REMOTE': '',
|
||||||
'PS4': '+(${BASH_SOURCE[0]-$0}:$LINENO) ',
|
'PS4': '+(${BASH_SOURCE[0]-$0}:$LINENO) ',
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
a = mkDerivation {
|
a = mkDerivation {
|
||||||
|
@ -8,6 +8,15 @@ TODO_NixOS
|
|||||||
|
|
||||||
requireSandboxSupport
|
requireSandboxSupport
|
||||||
|
|
||||||
|
start="$TEST_ROOT/start"
|
||||||
|
mkdir -p "$start"
|
||||||
|
cp -r common common.sh ${config_nix} ./nested-sandboxing "$start"
|
||||||
|
cp "${_NIX_TEST_BUILD_DIR}/common/subst-vars.sh" "$start/common"
|
||||||
|
# N.B. redefine
|
||||||
|
_NIX_TEST_SOURCE_DIR="$start"
|
||||||
|
_NIX_TEST_BUILD_DIR="$start"
|
||||||
|
cd "$start"
|
||||||
|
|
||||||
source ./nested-sandboxing/command.sh
|
source ./nested-sandboxing/command.sh
|
||||||
|
|
||||||
expectStderr 100 runNixBuild badStoreUrl 2 | grepQuiet '`sandbox-build-dir` must not contain'
|
expectStderr 100 runNixBuild badStoreUrl 2 | grepQuiet '`sandbox-build-dir` must not contain'
|
||||||
|
@ -19,6 +19,9 @@ mkDerivation {
|
|||||||
|
|
||||||
export PATH=${builtins.getEnv "NIX_BIN_DIR"}:$PATH
|
export PATH=${builtins.getEnv "NIX_BIN_DIR"}:$PATH
|
||||||
|
|
||||||
|
export _NIX_TEST_SOURCE_DIR=$PWD
|
||||||
|
export _NIX_TEST_BUILD_DIR=$PWD
|
||||||
|
|
||||||
source common.sh
|
source common.sh
|
||||||
source ./nested-sandboxing/command.sh
|
source ./nested-sandboxing/command.sh
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ drvPath=$(nix-instantiate dependencies.nix)
|
|||||||
nix copy --to file://$TEST_ROOT/foo?compression="bzip2" $(nix-store -r "$drvPath")
|
nix copy --to file://$TEST_ROOT/foo?compression="bzip2" $(nix-store -r "$drvPath")
|
||||||
rm -rf $TEST_ROOT/nixexprs
|
rm -rf $TEST_ROOT/nixexprs
|
||||||
mkdir -p $TEST_ROOT/nixexprs
|
mkdir -p $TEST_ROOT/nixexprs
|
||||||
cp config.nix dependencies.nix dependencies.builder*.sh $TEST_ROOT/nixexprs/
|
cp "${config_nix}" dependencies.nix dependencies.builder*.sh $TEST_ROOT/nixexprs/
|
||||||
ln -s dependencies.nix $TEST_ROOT/nixexprs/default.nix
|
ln -s dependencies.nix $TEST_ROOT/nixexprs/default.nix
|
||||||
(cd $TEST_ROOT && tar cvf - nixexprs) | bzip2 > $TEST_ROOT/foo/nixexprs.tar.bz2
|
(cd $TEST_ROOT && tar cvf - nixexprs) | bzip2 > $TEST_ROOT/foo/nixexprs.tar.bz2
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ printf World > $flake1Dir/who
|
|||||||
printf 1.0 > $flake1Dir/version
|
printf 1.0 > $flake1Dir/version
|
||||||
printf false > $flake1Dir/ca.nix
|
printf false > $flake1Dir/ca.nix
|
||||||
|
|
||||||
cp ./config.nix $flake1Dir/
|
cp "${config_nix}" $flake1Dir/
|
||||||
|
|
||||||
# Test upgrading from nix-env.
|
# Test upgrading from nix-env.
|
||||||
nix-env -f ./user-envs.nix -i foo-1.0
|
nix-env -f ./user-envs.nix -i foo-1.0
|
||||||
@ -140,7 +140,7 @@ nix profile install $(nix-build --no-out-link ./simple.nix)
|
|||||||
|
|
||||||
# Test packages with same name from different sources
|
# Test packages with same name from different sources
|
||||||
mkdir $TEST_ROOT/simple-too
|
mkdir $TEST_ROOT/simple-too
|
||||||
cp ./simple.nix ./config.nix simple.builder.sh $TEST_ROOT/simple-too
|
cp ./simple.nix "${config_nix}" simple.builder.sh $TEST_ROOT/simple-too
|
||||||
nix profile install --file $TEST_ROOT/simple-too/simple.nix ''
|
nix profile install --file $TEST_ROOT/simple-too/simple.nix ''
|
||||||
nix profile list | grep -A4 'Name:.*simple' | grep 'Name:.*simple-1'
|
nix profile list | grep -A4 'Name:.*simple' | grep 'Name:.*simple-1'
|
||||||
nix profile remove simple 2>&1 | grep 'removed 1 packages'
|
nix profile remove simple 2>&1 | grep 'removed 1 packages'
|
||||||
|
@ -79,7 +79,7 @@ sed -e "s|@ENV_PROG@|$(type -P env)|" shell.shebang.expr > $TEST_ROOT/shell.sheb
|
|||||||
chmod a+rx $TEST_ROOT/shell.shebang.expr
|
chmod a+rx $TEST_ROOT/shell.shebang.expr
|
||||||
# Should fail due to expressions using relative path
|
# Should fail due to expressions using relative path
|
||||||
! $TEST_ROOT/shell.shebang.expr bar
|
! $TEST_ROOT/shell.shebang.expr bar
|
||||||
cp shell.nix config.nix $TEST_ROOT
|
cp shell.nix "${config_nix}" $TEST_ROOT
|
||||||
# Should succeed
|
# Should succeed
|
||||||
echo "cwd: $PWD"
|
echo "cwd: $PWD"
|
||||||
output=$($TEST_ROOT/shell.shebang.expr bar)
|
output=$($TEST_ROOT/shell.shebang.expr bar)
|
||||||
@ -126,7 +126,7 @@ $TEST_ROOT/shell.shebang.nix
|
|||||||
mkdir $TEST_ROOT/lookup-test $TEST_ROOT/empty
|
mkdir $TEST_ROOT/lookup-test $TEST_ROOT/empty
|
||||||
|
|
||||||
echo "import $shellDotNix" > $TEST_ROOT/lookup-test/shell.nix
|
echo "import $shellDotNix" > $TEST_ROOT/lookup-test/shell.nix
|
||||||
cp config.nix $TEST_ROOT/lookup-test/
|
cp "${config_nix}" $TEST_ROOT/lookup-test/
|
||||||
echo 'abort "do not load default.nix!"' > $TEST_ROOT/lookup-test/default.nix
|
echo 'abort "do not load default.nix!"' > $TEST_ROOT/lookup-test/default.nix
|
||||||
|
|
||||||
nix-shell $TEST_ROOT/lookup-test -A shellDrv --run 'echo "it works"' | grepQuiet "it works"
|
nix-shell $TEST_ROOT/lookup-test -A shellDrv --run 'echo "it works"' | grepQuiet "it works"
|
||||||
|
@ -4,8 +4,8 @@ source common.sh
|
|||||||
|
|
||||||
clearStoreIfPossible
|
clearStoreIfPossible
|
||||||
|
|
||||||
outPath1=$(echo 'with import ./config.nix; mkDerivation { name = "foo1"; builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo"; }' | nix-build - --no-out-link --auto-optimise-store)
|
outPath1=$(echo 'with import '"${config_nix}"'; mkDerivation { name = "foo1"; builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo"; }' | nix-build - --no-out-link --auto-optimise-store)
|
||||||
outPath2=$(echo 'with import ./config.nix; mkDerivation { name = "foo2"; builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo"; }' | nix-build - --no-out-link --auto-optimise-store)
|
outPath2=$(echo 'with import '"${config_nix}"'; mkDerivation { name = "foo2"; builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo"; }' | nix-build - --no-out-link --auto-optimise-store)
|
||||||
|
|
||||||
TODO_NixOS # ignoring the client-specified setting 'auto-optimise-store', because it is a restricted setting and you are not a trusted user
|
TODO_NixOS # ignoring the client-specified setting 'auto-optimise-store', because it is a restricted setting and you are not a trusted user
|
||||||
# TODO: only continue when trusted user or root
|
# TODO: only continue when trusted user or root
|
||||||
@ -23,7 +23,7 @@ if [ "$nlink" != 3 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
outPath3=$(echo 'with import ./config.nix; mkDerivation { name = "foo3"; builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo"; }' | nix-build - --no-out-link)
|
outPath3=$(echo 'with import '"${config_nix}"'; mkDerivation { name = "foo3"; builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo"; }' | nix-build - --no-out-link)
|
||||||
|
|
||||||
inode3="$(stat --format=%i $outPath3/foo)"
|
inode3="$(stat --format=%i $outPath3/foo)"
|
||||||
if [ "$inode1" = "$inode3" ]; then
|
if [ "$inode1" = "$inode3" ]; then
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
, meson
|
, meson
|
||||||
, ninja
|
, ninja
|
||||||
, pkg-config
|
, pkg-config
|
||||||
, rsync
|
|
||||||
|
|
||||||
, jq
|
, jq
|
||||||
, git
|
, git
|
||||||
@ -52,7 +51,6 @@ mkMesonDerivation (finalAttrs: {
|
|||||||
meson
|
meson
|
||||||
ninja
|
ninja
|
||||||
pkg-config
|
pkg-config
|
||||||
rsync
|
|
||||||
|
|
||||||
jq
|
jq
|
||||||
git
|
git
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{sleepTime ? 3}:
|
{sleepTime ? 3}:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ source common.sh
|
|||||||
clearStoreIfPossible
|
clearStoreIfPossible
|
||||||
|
|
||||||
outPath=$(nix-build --no-out-link -E "
|
outPath=$(nix-build --no-out-link -E "
|
||||||
with import ./config.nix;
|
with import ${config_nix};
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = \"pass-as-file\";
|
name = \"pass-as-file\";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "filter";
|
name = "filter";
|
||||||
|
@ -5,7 +5,7 @@ source common.sh
|
|||||||
clearStoreIfPossible
|
clearStoreIfPossible
|
||||||
|
|
||||||
nix-build --no-out-link -E '
|
nix-build --no-out-link -E '
|
||||||
with import ./config.nix;
|
with import '"${config_nix}"';
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "placeholders";
|
name = "placeholders";
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
for ext in so dylib; do
|
for ext in so dylib; do
|
||||||
plugin="$PWD/plugins/libplugintest.$ext"
|
plugin="${_NIX_TEST_BUILD_DIR}/plugins/libplugintest.$ext"
|
||||||
[[ -f "$plugin" ]] && break
|
[[ -f "$plugin" ]] && break
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
with import ./config.nix;
|
let config_nix = /. + "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix"; in
|
||||||
|
with import config_nix;
|
||||||
|
|
||||||
mkDerivation rec {
|
mkDerivation rec {
|
||||||
name = "recursive";
|
name = "recursive";
|
||||||
@ -41,7 +42,7 @@ mkDerivation rec {
|
|||||||
|
|
||||||
# Build a derivation.
|
# Build a derivation.
|
||||||
nix $opts build -L --impure --expr '
|
nix $opts build -L --impure --expr '
|
||||||
with import ${./config.nix};
|
with import ${config_nix};
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "inner1";
|
name = "inner1";
|
||||||
buildCommand = "echo $fnord blaat > $out";
|
buildCommand = "echo $fnord blaat > $out";
|
||||||
|
@ -7,8 +7,19 @@ clearStoreIfPossible
|
|||||||
nix-instantiate --restrict-eval --eval -E '1 + 2'
|
nix-instantiate --restrict-eval --eval -E '1 + 2'
|
||||||
(! nix-instantiate --eval --restrict-eval ./restricted.nix)
|
(! nix-instantiate --eval --restrict-eval ./restricted.nix)
|
||||||
(! nix-instantiate --eval --restrict-eval <(echo '1 + 2'))
|
(! nix-instantiate --eval --restrict-eval <(echo '1 + 2'))
|
||||||
|
|
||||||
|
mkdir -p "$TEST_ROOT/nix"
|
||||||
|
cp ./simple.nix "$TEST_ROOT/nix"
|
||||||
|
cp ./simple.builder.sh "$TEST_ROOT/nix"
|
||||||
|
cp "${config_nix}" "$TEST_ROOT/nix"
|
||||||
|
simple_nix="$TEST_ROOT/nix/simple.nix"
|
||||||
|
# N.B. redefine
|
||||||
|
config_nix="$TEST_ROOT/nix/config.nix"
|
||||||
|
removeBuildDirRef "${simple_nix}"
|
||||||
|
cd "$TEST_ROOT/nix"
|
||||||
|
|
||||||
nix-instantiate --restrict-eval ./simple.nix -I src=.
|
nix-instantiate --restrict-eval ./simple.nix -I src=.
|
||||||
nix-instantiate --restrict-eval ./simple.nix -I src1=simple.nix -I src2=config.nix -I src3=./simple.builder.sh
|
nix-instantiate --restrict-eval ./simple.nix -I src1=./simple.nix -I src2=./config.nix -I src3=./simple.builder.sh
|
||||||
|
|
||||||
# no default NIX_PATH
|
# no default NIX_PATH
|
||||||
(unset NIX_PATH; ! nix-instantiate --restrict-eval --find-file .)
|
(unset NIX_PATH; ! nix-instantiate --restrict-eval --find-file .)
|
||||||
@ -19,25 +30,25 @@ nix-instantiate --restrict-eval --eval -E 'builtins.readFile ./simple.nix' -I sr
|
|||||||
expectStderr 1 nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in builtins.readFile <foo/simple.nix>' | grepQuiet "forbidden in restricted mode"
|
expectStderr 1 nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in builtins.readFile <foo/simple.nix>' | grepQuiet "forbidden in restricted mode"
|
||||||
nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in builtins.readFile <foo/simple.nix>' -I src=.
|
nix-instantiate --restrict-eval --eval -E 'let __nixPath = [ { prefix = "foo"; path = ./.; } ]; in builtins.readFile <foo/simple.nix>' -I src=.
|
||||||
|
|
||||||
p=$(nix eval --raw --expr "builtins.fetchurl file://$(pwd)/restricted.sh" --impure --restrict-eval --allowed-uris "file://$(pwd)")
|
p=$(nix eval --raw --expr "builtins.fetchurl file://${_NIX_TEST_SOURCE_DIR}/restricted.sh" --impure --restrict-eval --allowed-uris "file://${_NIX_TEST_SOURCE_DIR}")
|
||||||
cmp $p restricted.sh
|
cmp "$p" "${_NIX_TEST_SOURCE_DIR}/restricted.sh"
|
||||||
|
|
||||||
(! nix eval --raw --expr "builtins.fetchurl file://$(pwd)/restricted.sh" --impure --restrict-eval)
|
(! nix eval --raw --expr "builtins.fetchurl file://${_NIX_TEST_SOURCE_DIR}/restricted.sh" --impure --restrict-eval)
|
||||||
|
|
||||||
(! nix eval --raw --expr "builtins.fetchurl file://$(pwd)/restricted.sh" --impure --restrict-eval --allowed-uris "file://$(pwd)/restricted.sh/")
|
(! nix eval --raw --expr "builtins.fetchurl file://${_NIX_TEST_SOURCE_DIR}/restricted.sh" --impure --restrict-eval --allowed-uris "file://${_NIX_TEST_SOURCE_DIR}/restricted.sh/")
|
||||||
|
|
||||||
nix eval --raw --expr "builtins.fetchurl file://$(pwd)/restricted.sh" --impure --restrict-eval --allowed-uris "file://$(pwd)/restricted.sh"
|
nix eval --raw --expr "builtins.fetchurl file://${_NIX_TEST_SOURCE_DIR}/restricted.sh" --impure --restrict-eval --allowed-uris "file://${_NIX_TEST_SOURCE_DIR}/restricted.sh"
|
||||||
|
|
||||||
(! nix eval --raw --expr "builtins.fetchurl https://github.com/NixOS/patchelf/archive/master.tar.gz" --impure --restrict-eval)
|
(! nix eval --raw --expr "builtins.fetchurl https://github.com/NixOS/patchelf/archive/master.tar.gz" --impure --restrict-eval)
|
||||||
(! nix eval --raw --expr "builtins.fetchTarball https://github.com/NixOS/patchelf/archive/master.tar.gz" --impure --restrict-eval)
|
(! nix eval --raw --expr "builtins.fetchTarball https://github.com/NixOS/patchelf/archive/master.tar.gz" --impure --restrict-eval)
|
||||||
(! nix eval --raw --expr "fetchGit git://github.com/NixOS/patchelf.git" --impure --restrict-eval)
|
(! nix eval --raw --expr "fetchGit git://github.com/NixOS/patchelf.git" --impure --restrict-eval)
|
||||||
|
|
||||||
ln -sfn $(pwd)/restricted.nix $TEST_ROOT/restricted.nix
|
ln -sfn "${_NIX_TEST_SOURCE_DIR}/restricted.nix" "$TEST_ROOT/restricted.nix"
|
||||||
[[ $(nix-instantiate --eval $TEST_ROOT/restricted.nix) == 3 ]]
|
[[ $(nix-instantiate --eval $TEST_ROOT/restricted.nix) == 3 ]]
|
||||||
(! nix-instantiate --eval --restrict-eval $TEST_ROOT/restricted.nix)
|
(! nix-instantiate --eval --restrict-eval $TEST_ROOT/restricted.nix)
|
||||||
(! nix-instantiate --eval --restrict-eval $TEST_ROOT/restricted.nix -I $TEST_ROOT)
|
(! nix-instantiate --eval --restrict-eval $TEST_ROOT/restricted.nix -I $TEST_ROOT)
|
||||||
(! nix-instantiate --eval --restrict-eval $TEST_ROOT/restricted.nix -I .)
|
(! nix-instantiate --eval --restrict-eval $TEST_ROOT/restricted.nix -I .)
|
||||||
nix-instantiate --eval --restrict-eval $TEST_ROOT/restricted.nix -I $TEST_ROOT -I .
|
nix-instantiate --eval --restrict-eval "$TEST_ROOT/restricted.nix" -I "$TEST_ROOT" -I "${_NIX_TEST_SOURCE_DIR}"
|
||||||
|
|
||||||
[[ $(nix eval --raw --impure --restrict-eval -I . --expr 'builtins.readFile "${import ./simple.nix}/hello"') == 'Hello World!' ]]
|
[[ $(nix eval --raw --impure --restrict-eval -I . --expr 'builtins.readFile "${import ./simple.nix}/hello"') == 'Hello World!' ]]
|
||||||
|
|
||||||
@ -54,12 +65,12 @@ expectStderr 1 nix-instantiate --restrict-eval --eval -E "let __nixPath = [ { pr
|
|||||||
[[ $(nix-instantiate --restrict-eval --eval -E "let __nixPath = [ { prefix = \"foo\"; path = $TEST_ROOT/tunnel.d; } ]; in builtins.readDir <foo/tunnel>" -I $TEST_ROOT/tunnel.d) == '{ "tunnel.d" = "directory"; }' ]]
|
[[ $(nix-instantiate --restrict-eval --eval -E "let __nixPath = [ { prefix = \"foo\"; path = $TEST_ROOT/tunnel.d; } ]; in builtins.readDir <foo/tunnel>" -I $TEST_ROOT/tunnel.d) == '{ "tunnel.d" = "directory"; }' ]]
|
||||||
|
|
||||||
# Check whether we can leak symlink information through directory traversal.
|
# Check whether we can leak symlink information through directory traversal.
|
||||||
traverseDir="$(pwd)/restricted-traverse-me"
|
traverseDir="${_NIX_TEST_SOURCE_DIR}/restricted-traverse-me"
|
||||||
ln -sfn "$(pwd)/restricted-secret" "$(pwd)/restricted-innocent"
|
ln -sfn "${_NIX_TEST_SOURCE_DIR}/restricted-secret" "${_NIX_TEST_SOURCE_DIR}/restricted-innocent"
|
||||||
mkdir -p "$traverseDir"
|
mkdir -p "$traverseDir"
|
||||||
goUp="..$(echo "$traverseDir" | sed -e 's,[^/]\+,..,g')"
|
goUp="..$(echo "$traverseDir" | sed -e 's,[^/]\+,..,g')"
|
||||||
output="$(nix eval --raw --restrict-eval -I "$traverseDir" \
|
output="$(nix eval --raw --restrict-eval -I "$traverseDir" \
|
||||||
--expr "builtins.readFile \"$traverseDir/$goUp$(pwd)/restricted-innocent\"" \
|
--expr "builtins.readFile \"$traverseDir/$goUp${_NIX_TEST_SOURCE_DIR}/restricted-innocent\"" \
|
||||||
2>&1 || :)"
|
2>&1 || :)"
|
||||||
echo "$output" | grep "is forbidden"
|
echo "$output" | grep "is forbidden"
|
||||||
echo "$output" | grepInverse -F restricted-secret
|
echo "$output" | grepInverse -F restricted-secret
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
{
|
{
|
||||||
hello = mkDerivation rec {
|
hello = mkDerivation rec {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ requireDaemonNewerThan "2.6.0pre20211215"
|
|||||||
clearStoreIfPossible
|
clearStoreIfPossible
|
||||||
|
|
||||||
nix-build --no-out-link -E '
|
nix-build --no-out-link -E '
|
||||||
with import ./config.nix;
|
with import '"${config_nix}"';
|
||||||
|
|
||||||
let d1 = mkDerivation {
|
let d1 = mkDerivation {
|
||||||
name = "selfref-gc";
|
name = "selfref-gc";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
hello = mkDerivation {
|
hello = mkDerivation {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ inNixShell ? false, contentAddressed ? false, fooContents ? "foo" }:
|
{ inNixShell ? false, contentAddressed ? false, fooContents ? "foo" }:
|
||||||
|
|
||||||
let cfg = import ./config.nix; in
|
let cfg = import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix"; in
|
||||||
with cfg;
|
with cfg;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "simple-failing";
|
name = "simple-failing";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
name = "simple";
|
name = "simple";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
let
|
let
|
||||||
dep = mkDerivation {
|
dep = mkDerivation {
|
||||||
name = "dep";
|
name = "dep";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
let
|
let
|
||||||
foo_in_store = builtins.toFile "foo" "foo";
|
foo_in_store = builtins.toFile "foo" "foo";
|
||||||
|
@ -10,7 +10,7 @@ tarroot=$TEST_ROOT/tarball
|
|||||||
rm -rf "$tarroot"
|
rm -rf "$tarroot"
|
||||||
mkdir -p "$tarroot"
|
mkdir -p "$tarroot"
|
||||||
cp dependencies.nix "$tarroot/default.nix"
|
cp dependencies.nix "$tarroot/default.nix"
|
||||||
cp config.nix dependencies.builder*.sh "$tarroot/"
|
cp "${config_nix}" dependencies.builder*.sh "$tarroot/"
|
||||||
touch -d '@1000000000' "$tarroot" "$tarroot"/*
|
touch -d '@1000000000' "$tarroot" "$tarroot"/*
|
||||||
|
|
||||||
hash=$(nix hash path "$tarroot")
|
hash=$(nix hash path "$tarroot")
|
||||||
@ -45,7 +45,7 @@ test_tarball() {
|
|||||||
nix-instantiate --eval -E 'with <fnord/xyzzy>; 1 + 2' -I fnord=file:///no-such-tarball"$ext"
|
nix-instantiate --eval -E 'with <fnord/xyzzy>; 1 + 2' -I fnord=file:///no-such-tarball"$ext"
|
||||||
(! nix-instantiate --eval -E '<fnord/xyzzy> 1' -I fnord=file:///no-such-tarball"$ext")
|
(! nix-instantiate --eval -E '<fnord/xyzzy> 1' -I fnord=file:///no-such-tarball"$ext")
|
||||||
|
|
||||||
nix-instantiate --eval -E '<fnord/config.nix>' -I fnord=file:///no-such-tarball"$ext" -I fnord=.
|
nix-instantiate --eval -E '<fnord/config.nix>' -I fnord=file:///no-such-tarball"$ext" -I fnord="${_NIX_TEST_BUILD_DIR}"
|
||||||
|
|
||||||
# Ensure that the `name` attribute isn’t accepted as that would mess
|
# Ensure that the `name` attribute isn’t accepted as that would mess
|
||||||
# with the content-addressing
|
# with the content-addressing
|
||||||
|
@ -4,5 +4,5 @@ source common.sh
|
|||||||
|
|
||||||
drv="$(nix-instantiate simple.nix)"
|
drv="$(nix-instantiate simple.nix)"
|
||||||
cat "$drv"
|
cat "$drv"
|
||||||
out="$(./test-libstoreconsumer/test-libstoreconsumer "$drv")"
|
out="$("${_NIX_TEST_BUILD_DIR}/test-libstoreconsumer/test-libstoreconsumer" "$drv")"
|
||||||
grep -F "Hello World!" < "$out/hello"
|
grep -F "Hello World!" < "$out/hello"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{ foo ? "foo"
|
{ foo ? "foo"
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with import ./config.nix;
|
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||||
|
|
||||||
assert foo == "foo";
|
assert foo == "foo";
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ source common.sh
|
|||||||
|
|
||||||
clearStoreIfPossible
|
clearStoreIfPossible
|
||||||
|
|
||||||
cp ./dependencies.nix ./dependencies.builder0.sh ./config.nix $TEST_HOME
|
cp ./dependencies.nix ./dependencies.builder0.sh "${config_nix}" $TEST_HOME
|
||||||
|
|
||||||
cd $TEST_HOME
|
cd $TEST_HOME
|
||||||
|
|
||||||
|
@ -55,6 +55,10 @@ in
|
|||||||
-e 's!nix_tests += test-libstoreconsumer\.sh!!' \
|
-e 's!nix_tests += test-libstoreconsumer\.sh!!' \
|
||||||
;
|
;
|
||||||
|
|
||||||
|
_NIX_TEST_SOURCE_DIR="$(realpath tests/functional)"
|
||||||
|
export _NIX_TEST_SOURCE_DIR
|
||||||
|
export _NIX_TEST_BUILD_DIR="''${_NIX_TEST_SOURCE_DIR}"
|
||||||
|
|
||||||
export isTestOnNixOS=1
|
export isTestOnNixOS=1
|
||||||
export version=${config.nix.package.version}
|
export version=${config.nix.package.version}
|
||||||
export NIX_REMOTE_=daemon
|
export NIX_REMOTE_=daemon
|
||||||
|
Loading…
Reference in New Issue
Block a user