numtide / flake-utils

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

Should `filterPackages` check `meta.hydraPlatforms`? #73

Closed sigprof closed 2 years ago

sigprof commented 2 years ago

Currently filterPackages has this piece of code:

      platforms = meta.hydraPlatforms or meta.platforms or allSystems;

However, is checking meta.hydraPlatforms the proper thing here? Many packages use meta.hydraPlatforms = []; to mark “trivial” packages (e.g., wrappers like firefox) that are not really useful to cache on Hydra; this does not mean that the package does not build. There are other cases when meta.hydraPlatforms is empty (e.g., packages having non-free dependencies like NVidia drivers, or packages with outputs not fitting into Hydra limits). So if I want to reexport such packages from my flake, then I either cannot use filterPackages (which could otherwise be useful to avoid exporting packages that don't actually build for a particular system), or would need to patch out meta.hydraPlatform from packages (which does not seem to be right).

zimbatm commented 2 years ago

I don't remember the original reasoning. It's probably safe to remove it.

sigprof commented 2 years ago

Nixpkgs apparently does its platform check like this: https://github.com/NixOS/nixpkgs/blob/c49e4ce3fc0cebbe3e0cba75f0ea86bf28a76b1a/pkgs/stdenv/generic/check-meta.nix#L61-L63 And the result of this check is exposed as meta.unsupported in all derivations made with stdenv.mkDerivation. But it cannot be used to implement exactly the same filtering as done currently by filterPackages, because the Nixpkgs code uses hostPlatform.system instead of getting a system parameter (however, I'm not sure whether filtering packages already instantiated for one system while checking meta.platform against a different system name makes any sense).

BTW, another feature that the current filterPackages code does not support is meta.badPlatforms — some packages in Nixpkgs use that.