Skip to content

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

Closed
bb010g wants to merge 5 commits intonumtide:mainfrom
bb010g:systems-inputs
Closed

Factor out defaultSystems (→ systems) & allSystems to flake input#84
bb010g wants to merge 5 commits intonumtide:mainfrom
bb010g:systems-inputs

Conversation

@bb010g
Copy link

@bb010g bb010g commented Dec 14, 2022

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 bb010g force-pushed the systems-inputs branch 2 times, most recently from ec11d84 to fe93274 Compare December 14, 2022 05:35
@bb010g
Copy link
Author

bb010g commented Apr 6, 2023

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

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it took me a minute to get it. It's an interesting idea. It introduces a new pattern:

Instead of exposing allSystems and defaultSystems, have a single overridable systems input. The systems key would become a new convention to all flakes; if exposed, it allows you to control the systems with which the flake will be built.

If you agree with this convention then let's deprecate allSystems. Users can use nixpkgs.lib.platforms.all. And map defaultSystem to the systems input. Having only one extra input also helps keep the lock files small.

zimbatm added a commit to numtide/treefmt that referenced this pull request Apr 6, 2023
This is a new convention that lets consumers of the flake control what
systems this flake will be built with.

As a consumer you can pass your own list of systems, by overriding the
inputs. Eg:

```
inputs.systems.url = "path:./flake.systems.nix";
inputs.systems.flake = false;
inputs.treefmt.url = "github:numtide/treefmt";
inputs.treefmt.inputs.follows.systems = "systems";
```

Invented with the help of bb010g in numtide/flake-utils#84
@bb010g
Copy link
Author

bb010g commented Apr 7, 2023

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
Copy link
Author

bb010g commented Apr 7, 2023

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

zimbatm added a commit to numtide/treefmt that referenced this pull request Apr 7, 2023
This is a new convention that lets consumers of the flake control what
systems this flake will be built with.

As a consumer you can pass your own list of systems, by overriding the
inputs. Eg:

```
inputs.systems.url = "path:./flake.systems.nix";
inputs.systems.flake = false;
inputs.treefmt.url = "github:numtide/treefmt";
inputs.treefmt.inputs.follows.systems = "systems";
```

Invented with the help of bb010g in numtide/flake-utils#84
zimbatm added a commit to numtide/treefmt that referenced this pull request Apr 7, 2023
This is a new convention that lets consumers of the flake control what
systems this flake will be built with.

As a consumer you can pass your own list of systems, by overriding the
inputs. Eg:

```
inputs.systems.url = "path:./flake.systems.nix";
inputs.systems.flake = false;
inputs.treefmt.url = "github:numtide/treefmt";
inputs.treefmt.inputs.follows.systems = "systems";
```

Invented with the help of bb010g in numtide/flake-utils#84
@zimbatm
Copy link
Member

zimbatm commented Apr 7, 2023

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
Copy link
Author

bb010g commented Apr 7, 2023

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
Copy link
Member

zimbatm commented Apr 7, 2023

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
Copy link
Author

bb010g commented Apr 7, 2023

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

@bb010g bb010g changed the title Factor out defaultSystems & allSystems to flake inputs Factor out defaultSystems (→ systems) & allSystems to flake inputs Apr 7, 2023
bb010g added 4 commits April 8, 2023 09:39
This is an intermediary commit to help Git track file renames.
`./default.nix` provides backwards-compatibility.
A deprecated alias remains for backwards compatibility.
@bb010g bb010g force-pushed the systems-inputs branch 2 times, most recently from 80ef2a7 to c36a58b Compare April 8, 2023 10:02
@bb010g bb010g changed the title Factor out defaultSystems (→ systems) & allSystems to flake inputs Factor out defaultSystems (→ systems) & allSystems to flake input Apr 8, 2023
@bb010g
Copy link
Author

bb010g commented Apr 8, 2023

This flake input is overridable by downstreams and can be nicely
propagated throughout dependency trees via `follows`.
zimbatm added a commit to numtide/treefmt that referenced this pull request Apr 9, 2023
This is a new convention that lets consumers of the flake control what
systems this flake will be built with.

As a consumer you can pass your own list of systems, by overriding the
inputs. Eg:

```
inputs.systems.url = "path:./flake.systems.nix";
inputs.systems.flake = false;
inputs.treefmt.url = "github:numtide/treefmt";
inputs.treefmt.inputs.follows.systems = "systems";
```

Invented with the help of bb010g in numtide/flake-utils#84

See <https://github.com/nix-systems/nix-systems>
zimbatm added a commit that referenced this pull request Apr 9, 2023
This PR is a back-compatible subset of #84.

By adding a new flake input here, it makes it possible to override the
list of systems using flake overrides.

See <https://github.com/nix-systems/nix-systems> for the full
explanation.
zimbatm added a commit that referenced this pull request Apr 9, 2023
This PR is a back-compatible subset of #84.

By adding a new flake input here, it makes it possible to override the
list of systems using flake overrides.

See <https://github.com/nix-systems/nix-systems> for the full
explanation.
@zimbatm
Copy link
Member

zimbatm commented Apr 9, 2023

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

@zimbatm zimbatm closed this Apr 9, 2023
@bb010g bb010g deleted the systems-inputs branch April 9, 2023 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants