From b3c2281219893ee422e18f9d3917e8cc8216114d Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 20 Sep 2023 21:08:13 +0200 Subject: lib.fileset: Order noEval last --- lib/fileset/internal.nix | 12 ++++++++---- lib/fileset/tests.sh | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/fileset') diff --git a/lib/fileset/internal.nix b/lib/fileset/internal.nix index b3dbc5b33dc..43e6dd31b71 100644 --- a/lib/fileset/internal.nix +++ b/lib/fileset/internal.nix @@ -114,8 +114,10 @@ rec { # The one and only! _internalIsEmptyWithoutBase = true; - # Double __ to make it be evaluated and ordered first - __noEval = throw _noEvalMessage; + # Due to alphabetical ordering, this is evaluated last, + # which makes the nix repl output nicer than if it would be ordered first. + # It also allows evaluating it strictly up to this error, which could be useful + _noEval = throw _noEvalMessage; }; # Create a fileset, see ./README.md#fileset @@ -137,8 +139,10 @@ rec { _internalBaseComponents = components parts.subpath; _internalTree = tree; - # Double __ to make it be evaluated and ordered first - __noEval = throw _noEvalMessage; + # Due to alphabetical ordering, this is evaluated last, + # which makes the nix repl output nicer than if it would be ordered first. + # It also allows evaluating it strictly up to this error, which could be useful + _noEval = throw _noEvalMessage; }; # Coerce a value to a fileset, erroring when the value cannot be coerced. diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh index 525b8aaa917..1b53e33073e 100755 --- a/lib/fileset/tests.sh +++ b/lib/fileset/tests.sh @@ -84,14 +84,14 @@ expectStorePath() { crudeUnquoteJSON <<< "$result" } -# Check that a nix expression fails to evaluate (strictly, coercing to json, read-write-mode). +# Check that a nix expression fails to evaluate (strictly, read-write-mode). # And check the received stderr against a regex # The expression has `lib.fileset` in scope. # Usage: expectFailure NIX REGEX expectFailure() { local expr=$1 local expectedErrorRegex=$2 - if result=$(nix-instantiate --eval --strict --json --read-write-mode --show-trace 2>"$tmp/stderr" \ + if result=$(nix-instantiate --eval --strict --read-write-mode --show-trace 2>"$tmp/stderr" \ --expr "$prefixExpression $expr"); then die "$expr evaluated successfully to $result, but it was expected to fail" fi -- cgit 1.4.1