From 53c15336b06dcf26689c35fb3166ca6a4846b967 Mon Sep 17 00:00:00 2001 From: Tharun T Date: Mon, 25 Mar 2024 07:43:31 +0530 Subject: [PATCH 1/3] derivation output selection test --- tests/functional/flakes/flakes.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/functional/flakes/flakes.sh b/tests/functional/flakes/flakes.sh index 427290883f1..f6931a57897 100644 --- a/tests/functional/flakes/flakes.sh +++ b/tests/functional/flakes/flakes.sh @@ -285,6 +285,35 @@ git -C "$flake3Dir" add flake.lock git -C "$flake3Dir" commit -m 'Add lockfile' +# Test accessing output in installables with `.` (foobarbaz.) +cat > "$flake3Dir/flake.nix" < \$foo/file + echo "out" > \$out/file + ''; + outputSpecified = true; + }; + }; +} +EOF + +cp ../config.nix "$flake3Dir" +git -C "$flake3Dir" add flake.nix config.nix +git -C "$flake3Dir" commit -m 'multi outputs flake' + +nix build "$flake3Dir#hello.foo" --json --no-link | jq --exit-status ' + (.[0] | + (.drvPath | match(".*hello.drv")) and + (.outputs | keys == ["foo"])) +' + # Test whether registry caching works. nix registry list --flake-registry "file://$registry" | grepQuiet flake3 mv "$registry" "$registry.tmp" From 52359ca00ae1e3b3ae5ab831edb98ecdb9d5261a Mon Sep 17 00:00:00 2001 From: Tharun T Date: Thu, 28 Mar 2024 02:20:33 +0530 Subject: [PATCH 2/3] move test to correct file --- tests/functional/flakes/build-paths.sh | 19 +++++++++++++++++ tests/functional/flakes/flakes.sh | 29 -------------------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/tests/functional/flakes/build-paths.sh b/tests/functional/flakes/build-paths.sh index ff012e1b3bb..98827947deb 100644 --- a/tests/functional/flakes/build-paths.sh +++ b/tests/functional/flakes/build-paths.sh @@ -56,6 +56,18 @@ cat > $flake1Dir/flake.nix < \$foo/file + echo "out" > \$out/file + ''; + outputSpecified = true; + }; }; } EOF @@ -94,3 +106,10 @@ nix build --json --out-link $TEST_ROOT/result $flake1Dir#a12 expectStderr 1 nix build --impure --json --out-link $TEST_ROOT/result $flake1Dir#a13 \ | grepQuiet "has 2 entries in its context. It should only have exactly one entry" + +# Test accessing output in installables with `.` (foobarbaz.) +nix build --json --no-link $flake1Dir#a14.foo | jq --exit-status ' + (.[0] | + (.drvPath | match(".*dot-installable.drv")) and + (.outputs | keys == ["foo"])) +' diff --git a/tests/functional/flakes/flakes.sh b/tests/functional/flakes/flakes.sh index f6931a57897..427290883f1 100644 --- a/tests/functional/flakes/flakes.sh +++ b/tests/functional/flakes/flakes.sh @@ -285,35 +285,6 @@ git -C "$flake3Dir" add flake.lock git -C "$flake3Dir" commit -m 'Add lockfile' -# Test accessing output in installables with `.` (foobarbaz.) -cat > "$flake3Dir/flake.nix" < \$foo/file - echo "out" > \$out/file - ''; - outputSpecified = true; - }; - }; -} -EOF - -cp ../config.nix "$flake3Dir" -git -C "$flake3Dir" add flake.nix config.nix -git -C "$flake3Dir" commit -m 'multi outputs flake' - -nix build "$flake3Dir#hello.foo" --json --no-link | jq --exit-status ' - (.[0] | - (.drvPath | match(".*hello.drv")) and - (.outputs | keys == ["foo"])) -' - # Test whether registry caching works. nix registry list --flake-registry "file://$registry" | grepQuiet flake3 mv "$registry" "$registry.tmp" From 8d84de455e53e1cd503f8618ed90ef4b01dfc9ef Mon Sep 17 00:00:00 2001 From: Tharun T Date: Wed, 3 Apr 2024 08:26:42 +0530 Subject: [PATCH 3/3] outputSpecified doesnt exit in top attr-set --- tests/functional/flakes/build-paths.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/functional/flakes/build-paths.sh b/tests/functional/flakes/build-paths.sh index 98827947deb..4e5c6809567 100644 --- a/tests/functional/flakes/build-paths.sh +++ b/tests/functional/flakes/build-paths.sh @@ -57,16 +57,21 @@ cat > $flake1Dir/flake.nix < \$foo/file - echo "out" > \$out/file - ''; - outputSpecified = true; + a14 = with import ./config.nix; let + top = mkDerivation { + name = "dot-installable"; + outputs = [ "foo" "out" ]; + meta.outputsToInstall = [ "out" ]; + buildCommand = '' + mkdir \$foo \$out + echo "foo" > \$foo/file + echo "out" > \$out/file + ''; + }; + in top // { + foo = top.foo // { + outputSpecified = true; + }; }; }; }