Skip to content

introduce externally extensible systems#93

Merged
zimbatm merged 1 commit intomainfrom
externall-extensible-systems
Apr 9, 2023
Merged

introduce externally extensible systems#93
zimbatm merged 1 commit intomainfrom
externall-extensible-systems

Conversation

@zimbatm
Copy link
Member

@zimbatm zimbatm commented 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.

Thanks to @bb010g for the initial implementation and inspiration.

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 zimbatm merged commit 1c226cc into main Apr 9, 2023
@zimbatm zimbatm deleted the externall-extensible-systems branch April 9, 2023 10:34
zimbatm added a commit that referenced this pull request Apr 9, 2023
re-expose defaultSystems even if it doesn't make a lot of sense anymore,
to not break back-compat.
zimbatm added a commit that referenced this pull request Apr 9, 2023
re-expose defaultSystems even if it doesn't make a lot of sense anymore,
to not break back-compat.
lib = import ./.;

# Externally extensible flake systems. See <https://github.com/nix-systems/nix-systems>.
inputs.systems.url = "github:nix-systems/default";

Choose a reason for hiding this comment

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

Doesn't this introduce a new flake input for every flake-utils inputs? In my config this would add 11 new flake inputs.

You can also not overwrite nested inputs without repeating the URL making this not as useful as it could be.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right, those 11 flakes are now automatically externally extensible if they use defaultSystem or eachDefaultSystem. The nix-sytems/default flake is a few kilobytes big.

You can also not overwrite nested inputs without repeating the URL making this not as useful as it could be.

I don't understand this point. If the "follows" mechanism not working?

Choose a reason for hiding this comment

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

The nix-sytems/default flake is a few kilobytes big.

The size of the flake is not really a problem, but it still increases the number of flake inputs which slows down all download operations.

I don't understand this point. If the "follows" mechanism not working?

You cannot overwrite flake-utils systems input if flake-utils is a dependency of another flake unless nix knows the URL of the flake-utils input.

If you have project -> flake-utils -> systems then flake-utils URL must either be written in the flake input, it must follow another flake input where the URL is known or I think it may also work if it is part of the registry, otherwise nix complains about that.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you have project -> flake-utils -> systems then flake-utils URL must either be written in the flake input, it must follow another flake input where the URL is known or I think it may also work if it is part of the registry, otherwise nix complains about that.

Do you have an example of that?

So far the project I have, the diff is only two lines:

  1. + inputs.systems.url = "github:nix-systems/x86_64-linux";
  2. + flake-utils.inputs.systems.follows = "systems";

And all the other inputs that use flake-utils were already following "flake-utils"

Choose a reason for hiding this comment

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

Interesting 🤔 I just revisted that and I think I know what went wrong when I last tested this: I put a flake URI in follows which makes no sense. Thanks for the headsup!

Choose a reason for hiding this comment

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

and I think the annoyance I encountered was that you needed to add the url of the flake input otherwise you get

 ▶ nix flake metadata
error: cannot find flake 'flake:treefmt-nix' in the flake registries
(use '--show-trace' to show detailed location information)

which made overwriting nested flake inputs only half as nice.

@FlorianFranzen

This comment was marked as abuse.

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.

3 participants