Make config.nix shims

As requested in https://github.com/NixOS/nix/pull/11792#discussion_r1827034428
This commit is contained in:
John Ericson committed 2024-11-06 16:09:18 -05:00
1 parent e70c9bb06a
commit f7591bc6ed
56 files changed
+49 -77

No files matched your search

-3
View File
@@ -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 -1
View File
@@ -1,6 +1,6 @@
{ busybox }:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
let
+1 -1
View File
@@ -1,6 +1,6 @@
{ busybox, contentAddressed ? false }:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
let
+2
View File
@@ -0,0 +1,2 @@
# Shim to get generated file
import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/ca/config.nix"
+1 -1
View File
@@ -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;
-3
View File
@@ -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 -1
View File
@@ -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;
+1 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
dep1 = mkDerivation {
+1 -1
View File
@@ -1,6 +1,6 @@
{checkBuildId ? 0}:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
{
nondeterministic = mkDerivation {
-3
View File
@@ -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")
-9
View File
@@ -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
View File
@@ -0,0 +1,2 @@
# Shim to get generated file
import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix"
+1 -1
View File
@@ -1,5 +1,5 @@
{ hashInvalidator ? "" }:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
let {
+2
View 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 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
+1 -1
View File
@@ -1,6 +1,6 @@
{ destFile, seed }:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
mkDerivation {
name = "simple";
+1 -1
View File
@@ -1,5 +1,5 @@
{ busybox }:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
let
mkDerivation = args:
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
mkDerivation {
name = "filter";
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
-3
View File
@@ -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
-3
View File
@@ -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() {
-1
View File
@@ -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
-3
View File
@@ -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}: {
-2
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
x1 = mkDerivation {
name = "x1";
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
{ lockFifo ? null }:
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
mkDerivation {
name = "gc-runtime";
+1 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
import (
mkDerivation {
name = "foo";
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
bar = mkDerivation {
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
+1 -1
View File
@@ -1,6 +1,6 @@
{ var, value }:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
mkDerivation {
name = "test";
+1 -1
View File
@@ -1,6 +1,6 @@
{ mode }:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
mkDerivation (
{
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
a = mkDerivation {
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
+1 -1
View File
@@ -1,6 +1,6 @@
{sleepTime ? 3}:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
let
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
mkDerivation {
name = "filter";
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
let
-4
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
{
hello = mkDerivation rec {
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
{
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
rec {
hello = mkDerivation {
+1 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
mkDerivation {
name = "simple-failing";
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
mkDerivation {
name = "simple";
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
let
dep = mkDerivation {
name = "dep";
+1 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
let
+1 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
{
+1 -1
View File
@@ -2,7 +2,7 @@
{ foo ? "foo"
}:
with import "${builtins.getEnv "_NIX_TEST_BUILD_DIR"}/config.nix";
with import ./config.nix;
assert foo == "foo";