1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 19:23:54 +02:00

Flake schemas

This applies upstream https://github.com/NixOS/nix/pull/8892.
This commit is contained in:
Eelco Dolstra 2024-07-11 16:49:49 +02:00
parent 51583851a2
commit 6406619c44
25 changed files with 702 additions and 819 deletions

View file

@ -16,17 +16,6 @@ EOF
nix flake check $flakeDir
cat > $flakeDir/flake.nix <<EOF
{
outputs = { self }: {
overlay = finalll: prev: {
};
};
}
EOF
(! nix flake check $flakeDir)
cat > $flakeDir/flake.nix <<EOF
{
outputs = { self, ... }: {

View file

@ -15,9 +15,9 @@ 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} == {};
assert show_output.packages.output.children.someOtherSystem.filtered;
assert show_output.packages.output.children.${builtins.currentSystem}.children.default.derivationName == "simple";
assert show_output.legacyPackages.skipped;
true
'
@ -26,8 +26,8 @@ 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} == {};
assert show_output.packages.output.children.someOtherSystem.children.default.derivationName == "simple";
assert show_output.legacyPackages.skipped;
true
'
@ -36,34 +36,7 @@ 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 == { };
assert show_output.legacyPackages.output.children.${builtins.currentSystem}.children.hello.derivationName == "simple";
true
'
@ -83,7 +56,7 @@ 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";
assert show_output.legacyPackages.output.children.${builtins.currentSystem}.children.AAAAAASomeThingsFailToEvaluate.failed;
assert show_output.legacyPackages.output.children.${builtins.currentSystem}.children.simple.derivationName == "simple";
true
'

View file

@ -32,4 +32,6 @@ cat << EOF > flake.nix
EOF
nix fmt ./file ./folder | grep 'Formatting: ./file ./folder'
nix flake check
nix flake show | grep -P "package 'formatter'"
clearStore
nix flake show | grep -P "package.*\[formatter\]"