numtide / flake-utils

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

Factor out `defaultSystems` (→ `systems`) & `allSystems` to flake input #84

Closed bb010g closed 1 year ago

bb010g commented 1 year ago

This patch set allows for easy overriding of systems lists downstream via flake inputs, in a library-agnostic way. Ideally, all flakes that consume systems lists will avoid hard-coding them and instead consume them via flake inputs, allowing systems to be robustly introduced to or removed from evaluation. Flake inputs consisting of these pure, plain Nix source files should be the lowest-common denominator for systems list concerns.

Compatibility with existing direct access of default.nix is maintained. If that interface is not stable, then the introduction of lib.nix can be eliminated.

The defaultSystems input in flake-utils is the same as the systems input in https://github.com/divnix/nosys.

bb010g commented 1 year ago

Any thoughts / concerns about this concept and/or implementation?

bb010g commented 1 year ago

As long as changing systems doesn't cause unnecessary reevaluations, then I'm good with dropping the defaultSystems / allSystems divide. Cc/ @nrdxp since I stole this from them.

EDIT: Removing allSystems does cause problems for flakeUtils.lib.system, as it validates against allSystems.

bb010g commented 1 year ago

I tried the defaultSystemssystems rename anyways, and it results in a few breaking changes.

zimbatm commented 1 year ago

Sorry, I meant only expose a single input called systems, and connect it to defaultSystems.nix. Ignore or deprecate allSystems. flake-utils is stable so we shouldn't break back-compat.

bb010g commented 1 year ago

What do you want to do about eachDefaultSystem and eachDefaultSystemMap? They can't directly rename to eachSystem and eachSystemMap because those names are taken by the parameterized variants.

zimbatm commented 1 year ago

I would keep all the library functions as is. allSystems is not overridable, but that's fine; I don't think people are really using it.

If it's unclear, push the previous version and I will do the changes.

bb010g commented 1 year ago

Alright, dropped all of the breaking renames (all but defaultSystemssystems) and kept backwards compatibility.

bb010g commented 1 year ago

Alright, reorganized and cleaned up using your ideas from https://github.com/numtide/treefmt/pull/228 and https://github.com/zimbatm/exp-flake-systems.

zimbatm commented 1 year ago

thanks for your help! #93 introduces what I had in mind, I hope you won't mind me closing this PR