Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make self'/self and inputs'/inputs more similar #153

Open
Pacman99 opened this issue May 8, 2023 · 1 comment
Open

Make self'/self and inputs'/inputs more similar #153

Pacman99 opened this issue May 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Pacman99
Copy link

Pacman99 commented May 8, 2023

Opened #152 but then I realized that it is probably not a good idea, because it seems self' and inputs' are picky about what they include for some reason.

So I just have a general question and possibly a feature request: Can self' and self and inputs' and inputs be more similar?. It seems only attributes that flake-parts supports are "de-systemized" in inputs', but why not just pick out any attribute thats system spaced and include all the original attributes in the flake. Then maybe the self' and self distinction won't even be necessary. Something like how de-systemizing is done here could be goo https://github.com/divnix/nosys/blob/master/desys.nix.

Maybe I'm misunderstanding flake-parts philosophy or architecture, but it seems unnecessary to have such a big distinction between concepts that are so similar.

@roberth
Copy link
Member

roberth commented May 8, 2023

philosophy or architecture

It is meant to be quite conservative and unopinionated, while extensible. This way, flake-parts has a chance of gluing together all flake logic, instead of a niche that is ok with many assumptions.

As a real world example, by not merging self' into self, we can have attributes that are meaningful in both contexts:

  • self.nixosConfigurations: a precise mapping of how each machine is configured
  • self'.nixosConfigurations: all the ways you could cross compile the configuration of each machine

Admittedly this may be a niche interpretation of nixosConfigurations, as it reinterprets the system attribute as the buildPlatform instead of the more usual hostPlatform, which is implied by nix run, nix develop, etc.
(I guess the role of system is about as arbitrary as the values defined for it; appears rigid, but is a bit arbitrary. All I've teased out is "whatever the CLI uses it for." - and I'm on the team...)

On the flip side, there's a lot you can actually modify from the comfort of your own modules. For instance, you could merge a very broad definition into perInput. I think it respects priorities, so you could probably add mapAttrs (k: mkDefault) and achieve the goal of merging self into self'.

I would recommend not to rely on that if you're going to write reusable modules for a large audience, but if it helps your own flakes, then why not?

@roberth roberth added the enhancement New feature or request label Jan 29, 2024
shymega pushed a commit to shymega/flake-parts that referenced this issue Aug 18, 2024
shymega pushed a commit to shymega/flake-parts that referenced this issue Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants