2020-10-23 13:20:38 +00:00
|
|
|
source common.sh
|
|
|
|
|
2022-03-24 22:36:14 +00:00
|
|
|
clearStore
|
|
|
|
|
2022-04-22 13:17:01 +00:00
|
|
|
set -o pipefail
|
2022-03-24 22:36:14 +00:00
|
|
|
|
2022-04-20 14:39:47 +00:00
|
|
|
# Make sure that 'nix build' returns all outputs by default.
|
|
|
|
nix build -f multiple-outputs.nix --json a b --no-link | jq --exit-status '
|
2020-10-23 13:20:38 +00:00
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
2021-02-12 21:51:36 +00:00
|
|
|
(.outputs |
|
2022-03-25 16:46:28 +00:00
|
|
|
(keys | length == 2) and
|
2021-02-12 21:51:36 +00:00
|
|
|
(.first | match(".*multiple-outputs-a-first")) and
|
|
|
|
(.second | match(".*multiple-outputs-a-second"))))
|
2020-10-23 13:20:38 +00:00
|
|
|
and (.[1] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-b.drv")) and
|
2022-03-25 16:46:28 +00:00
|
|
|
(.outputs |
|
|
|
|
(keys | length == 1) and
|
|
|
|
(.out | match(".*multiple-outputs-b"))))
|
2020-10-23 13:20:38 +00:00
|
|
|
'
|
2022-03-24 22:36:14 +00:00
|
|
|
|
2022-04-22 13:17:01 +00:00
|
|
|
# Test output selection using the '^' syntax.
|
|
|
|
nix build -f multiple-outputs.nix --json a^first --no-link | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
|
|
|
(.outputs | keys == ["first"]))
|
|
|
|
'
|
|
|
|
|
|
|
|
nix build -f multiple-outputs.nix --json a^second,first --no-link | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
|
|
|
(.outputs | keys == ["first", "second"]))
|
|
|
|
'
|
|
|
|
|
|
|
|
nix build -f multiple-outputs.nix --json 'a^*' --no-link | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
|
|
|
(.outputs | keys == ["first", "second"]))
|
|
|
|
'
|
|
|
|
|
|
|
|
# Test that 'outputsToInstall' is respected by default.
|
|
|
|
nix build -f multiple-outputs.nix --json e --no-link | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
2023-01-18 13:14:29 +00:00
|
|
|
(.outputs | keys == ["a_a", "b"]))
|
2022-04-22 13:17:01 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
# But not when it's overriden.
|
2023-01-18 13:14:29 +00:00
|
|
|
nix build -f multiple-outputs.nix --json e^a_a --no-link
|
|
|
|
nix build -f multiple-outputs.nix --json e^a_a --no-link | jq --exit-status '
|
2022-04-22 13:17:01 +00:00
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
2023-01-18 13:14:29 +00:00
|
|
|
(.outputs | keys == ["a_a"]))
|
2022-04-22 13:17:01 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
nix build -f multiple-outputs.nix --json 'e^*' --no-link | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
2023-01-18 13:14:29 +00:00
|
|
|
(.outputs | keys == ["a_a", "b", "c"]))
|
2022-04-22 13:17:01 +00:00
|
|
|
'
|
|
|
|
|
2022-12-12 22:34:57 +00:00
|
|
|
# Test building from raw store path to drv not expression.
|
|
|
|
|
|
|
|
drv=$(nix eval -f multiple-outputs.nix --raw a.drvPath)
|
|
|
|
if nix build "$drv^not-an-output" --no-link --json; then
|
|
|
|
fail "'not-an-output' should fail to build"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if nix build "$drv^" --no-link --json; then
|
|
|
|
fail "'empty outputs list' should fail to build"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if nix build "$drv^*nope" --no-link --json; then
|
|
|
|
fail "'* must be entire string' should fail to build"
|
|
|
|
fi
|
|
|
|
|
|
|
|
nix build "$drv^first" --no-link --json | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
|
|
|
(.outputs |
|
|
|
|
(keys | length == 1) and
|
|
|
|
(.first | match(".*multiple-outputs-a-first")) and
|
|
|
|
(has("second") | not)))
|
|
|
|
'
|
|
|
|
|
|
|
|
nix build "$drv^first,second" --no-link --json | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
|
|
|
(.outputs |
|
|
|
|
(keys | length == 2) and
|
|
|
|
(.first | match(".*multiple-outputs-a-first")) and
|
2023-01-18 15:33:39 +00:00
|
|
|
(.second | match(".*multiple-outputs-a-second"))))
|
2022-12-12 22:34:57 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
nix build "$drv^*" --no-link --json | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-a.drv")) and
|
|
|
|
(.outputs |
|
|
|
|
(keys | length == 2) and
|
|
|
|
(.first | match(".*multiple-outputs-a-first")) and
|
2023-01-18 15:33:39 +00:00
|
|
|
(.second | match(".*multiple-outputs-a-second"))))
|
2022-12-12 22:34:57 +00:00
|
|
|
'
|
|
|
|
|
2022-05-05 12:53:59 +00:00
|
|
|
# Make sure that `--impure` works (regression test for https://github.com/NixOS/nix/issues/6488)
|
|
|
|
nix build --impure -f multiple-outputs.nix --json e --no-link | jq --exit-status '
|
|
|
|
(.[0] |
|
|
|
|
(.drvPath | match(".*multiple-outputs-e.drv")) and
|
2023-01-18 13:14:29 +00:00
|
|
|
(.outputs | keys == ["a_a", "b"]))
|
2022-05-05 12:53:59 +00:00
|
|
|
'
|