mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 00:39:37 +01:00
Merge pull request #8871 from teto/flake_show_attr
nix flake show: name attribute that must be a derivation
This commit is contained in:
commit
5462c5eedd
2 changed files with 27 additions and 2 deletions
|
|
@ -1324,8 +1324,10 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
|||
try {
|
||||
if (visitor.isDerivation())
|
||||
showDerivation();
|
||||
else
|
||||
throw Error("expected a derivation");
|
||||
else {
|
||||
auto name = visitor.getAttrPathStr(state->s.name);
|
||||
logger->warn(fmt("%s is not a derivation", name));
|
||||
}
|
||||
} catch (IFDError & e) {
|
||||
if (!json) {
|
||||
logger->cout(
|
||||
|
|
|
|||
|
|
@ -107,3 +107,26 @@ in
|
|||
assert show_output.packages.${builtins.currentSystem}.default == { };
|
||||
true
|
||||
'
|
||||
|
||||
|
||||
# Test that nix keeps going even when packages.$SYSTEM contains not derivations
|
||||
cat >flake.nix <<EOF
|
||||
{
|
||||
outputs = inputs: {
|
||||
packages.$system = {
|
||||
drv1 = import ./simple.nix;
|
||||
not-a-derivation = 42;
|
||||
drv2 = import ./simple.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
EOF
|
||||
nix flake show --json --all-systems > show-output.json
|
||||
# shellcheck disable=SC2016
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
assert show_output.packages.${builtins.currentSystem}.not-a-derivation == {};
|
||||
true
|
||||
'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue