mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
60d48eda23
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.
66 lines
1.8 KiB
Bash
66 lines
1.8 KiB
Bash
source ./common.sh
|
|
|
|
flakeDir=$TEST_ROOT/flake
|
|
mkdir -p "$flakeDir"
|
|
|
|
writeSimpleFlake "$flakeDir"
|
|
cd "$flakeDir"
|
|
|
|
|
|
# By default: Only show the packages content for the current system and no
|
|
# legacyPackages at all
|
|
nix flake show --json > show-output.json
|
|
nix eval --impure --expr '
|
|
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
|
in
|
|
assert show_output.packages.someOtherSystem.default == {};
|
|
assert show_output.packages.${builtins.currentSystem}.default.name == "simple";
|
|
assert show_output.legacyPackages.${builtins.currentSystem} == {};
|
|
true
|
|
'
|
|
|
|
# With `--all-systems`, show the packages for all systems
|
|
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.packages.someOtherSystem.default.name == "simple";
|
|
assert show_output.legacyPackages.${builtins.currentSystem} == {};
|
|
true
|
|
'
|
|
|
|
# With `--legacy`, show the legacy packages
|
|
nix flake show --json --legacy > show-output.json
|
|
nix eval --impure --expr '
|
|
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
|
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
|
|
'
|