mirror of
https://github.com/NixOS/nix.git
synced 2025-11-29 13:41:00 +01:00
Merge remote-tracking branch 'origin/master' into lazy-trees
This commit is contained in:
commit
bb421ac80b
108 changed files with 1242 additions and 452 deletions
|
|
@ -20,6 +20,10 @@ writeSimpleFlake() {
|
|||
foo = import ./simple.nix;
|
||||
default = foo;
|
||||
};
|
||||
packages.someOtherSystem = rec {
|
||||
foo = import ./simple.nix;
|
||||
default = foo;
|
||||
};
|
||||
|
||||
# To test "nix flake init".
|
||||
legacyPackages.x86_64-linux.hello = import ./simple.nix;
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ cat > $templatesDir/trivial/flake.nix <<EOF
|
|||
description = "A flake for building Hello World";
|
||||
|
||||
outputs = { self, nixpkgs }: {
|
||||
packages.x86_64-linux = rec {
|
||||
hello = nixpkgs.legacyPackages.x86_64-linux.hello;
|
||||
packages.$system = rec {
|
||||
hello = nixpkgs.legacyPackages.$system.hello;
|
||||
default = hello;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
66
tests/flakes/show.sh
Normal file
66
tests/flakes/show.sh
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
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
|
||||
'
|
||||
Loading…
Add table
Add a link
Reference in a new issue