aboutsummaryrefslogtreecommitdiff
path: root/tests/flakes
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-01-31 18:16:31 +0100
committerRobert Hensing <robert@roberthensing.nl>2023-01-31 18:20:26 +0100
commit60d48eda2354dfa6d23ed3feb7b23ac25b34edcf (patch)
treed6cbc5e1da134f6b565f01e01105aa6747e3e547 /tests/flakes
parentc9b9260f348299aad70ea2010db6e291ee1e8114 (diff)
nix flake show: Ignore empty attrsets
For frameworks it's important that structures are as lazy as possible to prevent infinite recursions, performance issues and errors that aren't related to the thing to evaluate. As a consequence, they have to emit more attributes than strictly (sic) necessary. However, these attributes with empty values are not useful to the user so we omit them.
Diffstat (limited to 'tests/flakes')
-rw-r--r--tests/flakes/show.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/flakes/show.sh b/tests/flakes/show.sh
index 995de8dc3..dd13264b9 100644
--- a/tests/flakes/show.sh
+++ b/tests/flakes/show.sh
@@ -37,3 +37,30 @@ in
assert show_output.legacyPackages.${builtins.currentSystem}.hello.name == "simple";
true
'
+
+# Test that attributes are only reported when they have actual content
+cat >flake.nix <<EOF
+{
+ description = "Bla bla";
+
+ outputs = inputs: rec {
+ apps.$system = { };
+ checks.$system = { };
+ devShells.$system = { };
+ legacyPackages.$system = { };
+ packages.$system = { };
+ packages.someOtherSystem = { };
+
+ formatter = { };
+ nixosConfigurations = { };
+ nixosModules = { };
+ };
+}
+EOF
+nix flake show --json --all-systems > show-output.json
+nix eval --impure --expr '
+let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
+in
+assert show_output == { };
+true
+'