numtide / flake-utils

Pure Nix flake utility functions [maintainer=@zimbatm]
MIT License
1.14k stars 78 forks source link

`flattenTree` cannot seem to flatten `legacyPackages` to a `packages`-compatible format #72

Closed shadowrylander closed 2 years ago

shadowrylander commented 2 years ago

Describe the bug

flattenTree cannot seem to flatten legacyPackages to a packages-compatible format; the resulting attribute set is empty.

To Reproduce

Steps to reproduce the behavior:

legacyPackages = import nixpkgs {};
# packages = flattenTree legacyPackages;
# packages = flattenTree (mapAttrs (n: v: legacyPackages.${n}) legacyPackages);
# packages = flattenTree (genAttrs (attrNames legacyPackages) (pkg: legacyPackages.${pkg}));
packages = flattenTree { hello = legacyPackages.hello; };

The commented packages assignments all fail, while the last one succeeds, verified by trace packages.

Expected behavior

I thought the commented assignments result in the same attribute sets as the last assignment.

System information

NixOS 22.05, using nix (Nix) 2.5.0pre20211206_d1aaa7e and the master branch flake-utils.

Additional context

Here is the actual config, as opposed to the minimal example above.

shadowrylander commented 2 years ago

Sorry; just understood the error. What measures does Hydra take to handle failing packages, or where can I find them? This, for example, gets killed:

filterAttrs (n: v: all (b: b == true) [
    (! elem n [ "prometheus-dmarc-exporter" ])
    (tryEval v).success
    ((isDerivation v) && (v ? meta) && (v.meta ? broken))
]) legacyPackages
zimbatm commented 2 years ago

Most likely this will also use a ton of memory. flattenTree probably shouldn't be used like that :sweat_smile:

shadowrylander commented 2 years ago

Aww... 😹 Ah, well; I guess I could just use legacyPAckages. Could you tell me the difference between it and packages, actually?

zimbatm commented 2 years ago

The only difference is when using nix flake check, it will complain if packages isn't a flat attrset of packages only. legacyPackages allows any types of values. When you use commands like nix run it will look into both, and prioritize packages over legacyPackages.

shadowrylander commented 2 years ago

Ah; makes sense. Thanks for the clarification!