mirror of
https://github.com/NixOS/nix.git
synced 2024-11-21 14:22:29 +00:00
Make config.nix
shims
As requested in https://github.com/NixOS/nix/pull/11792#discussion_r1827034428
This commit is contained in:
parent
e70c9bb06a
commit
f7591bc6ed
3
.gitignore
vendored
3
.gitignore
vendored
@ -102,9 +102,6 @@ perl/Makefile.config
|
||||
/tests/functional/restricted-innocent
|
||||
/tests/functional/shell
|
||||
/tests/functional/shell.drv
|
||||
/tests/functional/config.nix
|
||||
/tests/functional/ca/config.nix
|
||||
/tests/functional/dyn-drv/config.nix
|
||||
/tests/functional/repl-result-out
|
||||
/tests/functional/debugger-test-out
|
||||
/tests/functional/test-libstoreconsumer/test-libstoreconsumer
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ busybox }:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ busybox, contentAddressed ? false }:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let
|
||||
|
||||
|
2
tests/functional/ca/config.nix
Normal file
2
tests/functional/ca/config.nix
Normal file
@ -0,0 +1,2 @@
|
||||
# Shim to get generated file
|
||||
import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/ca/config.nix"
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/ca/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let mkCADerivation = args: mkDerivation ({
|
||||
__contentAddressed = true;
|
||||
|
@ -6,7 +6,4 @@ flakeDir="$TEST_HOME/flake"
|
||||
mkdir -p "${flakeDir}"
|
||||
cp flake.nix "${_NIX_TEST_BUILD_DIR}/ca/config.nix" content-addressed.nix "${flakeDir}"
|
||||
|
||||
# `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"
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/ca/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let mkCADerivation = args: mkDerivation ({
|
||||
__contentAddressed = true;
|
||||
|
@ -2,7 +2,7 @@
|
||||
# build it at once.
|
||||
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/ca/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "simple";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
dep1 = mkDerivation {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{checkBuildId ? 0}:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
{
|
||||
nondeterministic = mkDerivation {
|
||||
|
@ -39,9 +39,6 @@ EOF
|
||||
|
||||
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
|
||||
|
||||
outPath=$(nix build --print-out-paths --no-link --sandbox-paths '/nix? /bin? /lib? /lib64? /usr?' --store "$TEST_ROOT/x" path:"$flakeDir")
|
||||
|
@ -343,15 +343,6 @@ count() {
|
||||
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
|
||||
|
||||
fi # COMMON_FUNCTIONS_SH_SOURCED
|
||||
|
2
tests/functional/config.nix
Normal file
2
tests/functional/config.nix
Normal file
@ -0,0 +1,2 @@
|
||||
# Shim to get generated file
|
||||
import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix"
|
@ -1,5 +1,5 @@
|
||||
{ hashInvalidator ? "" }:
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let {
|
||||
|
||||
|
2
tests/functional/dyn-drv/config.nix
Normal file
2
tests/functional/dyn-drv/config.nix
Normal file
@ -0,0 +1,2 @@
|
||||
# Shim to get generated file
|
||||
import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/dyn-drv/config.nix"
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/dyn-drv/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
# A simple content-addressed derivation.
|
||||
# The derivation can be arbitrarily modified by passing a different `seed`,
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/dyn-drv/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let innerName = "foo"; in
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/dyn-drv/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
# A simple content-addressed derivation.
|
||||
# The derivation can be arbitrarily modified by passing a different `seed`,
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ destFile, seed }:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "simple";
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ busybox }:
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
let
|
||||
|
||||
mkDerivation = args:
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "filter";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
|
@ -4,9 +4,6 @@ source common.sh
|
||||
|
||||
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"
|
||||
|
||||
cat <<EOF > flake.nix
|
||||
|
@ -35,9 +35,6 @@ writeSimpleFlake() {
|
||||
EOF
|
||||
|
||||
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() {
|
||||
|
@ -3,7 +3,6 @@
|
||||
source common.sh
|
||||
|
||||
cp ../simple.nix ../simple.builder.sh "${config_nix}" $TEST_HOME
|
||||
removeBuildDirRef "$TEST_HOME/simple.nix"
|
||||
|
||||
cd $TEST_HOME
|
||||
|
||||
|
@ -27,9 +27,6 @@ EOF
|
||||
mkdir -p "$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"
|
||||
{
|
||||
outputs = {self}: {
|
||||
|
@ -8,8 +8,6 @@ clearStore
|
||||
rm -rf $TEST_HOME/.cache $TEST_HOME/.config $TEST_HOME/.local
|
||||
|
||||
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
|
||||
|
||||
cat <<EOF > flake.nix
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
rec {
|
||||
x1 = mkDerivation {
|
||||
name = "x1";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
{ lockFifo ? null }:
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "gc-runtime";
|
||||
|
@ -5,7 +5,7 @@
|
||||
, withFinalRefs ? false
|
||||
}:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let
|
||||
contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
import (
|
||||
mkDerivation {
|
||||
name = "foo";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
bar = mkDerivation {
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ var, value }:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "test";
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ mode }:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation (
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
a = mkDerivation {
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{sleepTime ? 3}:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "filter";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let
|
||||
|
||||
|
@ -12,10 +12,6 @@ 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=.
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
{
|
||||
hello = mkDerivation rec {
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
{
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
hello = mkDerivation {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ inNixShell ? false, contentAddressed ? false, fooContents ? "foo" }:
|
||||
|
||||
let cfg = import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix"; in
|
||||
let cfg = import ./config.nix; in
|
||||
with cfg;
|
||||
|
||||
let
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "simple-failing";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "simple";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
let
|
||||
dep = mkDerivation {
|
||||
name = "dep";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
let
|
||||
foo_in_store = builtins.toFile "foo" "foo";
|
||||
|
@ -1,4 +1,4 @@
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
{
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
{ foo ? "foo"
|
||||
}:
|
||||
|
||||
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
|
||||
with import ./config.nix;
|
||||
|
||||
assert foo == "foo";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user