aboutsummaryrefslogtreecommitdiff
path: root/tests/flakes/show.sh
diff options
context:
space:
mode:
authoroxalica <oxalicc@pm.me>2023-03-26 22:39:24 +0800
committeroxalica <oxalicc@pm.me>2023-03-26 23:05:29 +0800
commit2941a599fa6c9fec5d084cec2cb5da3752efc5f8 (patch)
tree4c7b2c993e69e3afe43ac63e314e0112314272d5 /tests/flakes/show.sh
parente00abd3f566b16bb107d513925cf33b40cca35f4 (diff)
Catch eval errors in `hasContent`
`legacyPackages` of nixpkgs trigger eval errors in `hasContent`, causing the whole `legacyPackages` being skipped. We should treat it as has-content in that case.
Diffstat (limited to 'tests/flakes/show.sh')
-rw-r--r--tests/flakes/show.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/flakes/show.sh b/tests/flakes/show.sh
index dd13264b9..6f886ccfb 100644
--- a/tests/flakes/show.sh
+++ b/tests/flakes/show.sh
@@ -64,3 +64,23 @@ in
assert show_output == { };
true
'
+
+# Test that legacyPackages with errors are handled correctly.
+cat >flake.nix <<EOF
+{
+ outputs = inputs: {
+ legacyPackages.$system = {
+ AAAAAASomeThingsFailToEvaluate = throw "nooo";
+ simple = import ./simple.nix;
+ };
+ };
+}
+EOF
+nix flake show --json --legacy --all-systems > show-output.json
+nix eval --impure --expr '
+let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
+in
+assert show_output.legacyPackages.${builtins.currentSystem}.AAAAAASomeThingsFailToEvaluate == { };
+assert show_output.legacyPackages.${builtins.currentSystem}.simple.name == "simple";
+true
+'