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

systemFlake: make one unified outputsBuilder #58

Closed
wants to merge 2 commits into from

Conversation

Pacman99
Copy link
Collaborator

@Pacman99 Pacman99 commented May 17, 2021

replace output-specific builders

This is actually much simpler to implement than the old method. And the code looks waay better.

The hardest part is deprecating the current output-specific builders. I have no idea how to do that. I have tried many things like filtering for builders that return null. Either we end up with the flake just creating all the outputs, or infinite recursion when filtering.

implements/closes #56

@Pacman99 Pacman99 marked this pull request as draft May 17, 2021 18:47
Comment on lines +22 to +29
, outputsBuilder ? channels: {
packages = packagesBuilder channels;
defaultPackage = defaultPackageBuilder channels;
apps = appsBuilder channels;
defaultApp = defaultAppBuilder channels;
devShell = devShellBuilder channels;
checks = checksBuilder channels;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As you can imagine, this would have a couple consequences.

  • We create all the outputs whether users want them or not
  • I think flake check errors out from empty attrsets in defaultPackage and defaultApp

Choose a reason for hiding this comment

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

Maybe we can use something like this instead?

        deprecatedBuilders = channels: {}
          // optionalAttrs (packagesBuilder != null) (packagesBuilder channels)
          // optionalAttrs (defaultPackageBuilder != null) (defaultPackageBuilder channels)
          // optionalAttrs (appsBuilder != null) (appsBuilder channels)
          // optionalAttrs (defaultAppBuilder != null) (defaultAppBuilder channels)
          // optionalAttrs (devShellBuilder != null) (devShellBuilder channels)
          // optionalAttrs (checksBuilder != null) (checksBuilder channels);

Comment on lines +201 to +203
outputs = mapAttrs
(outputName: output: otherArguments.${outputName}.${system} or { } // output)
(outputsBuilder pkgs);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've tried filtering for empty attrsets or null here, but that can cause infinite recursion if any output depends on another.

Copy link
Collaborator

@blaggacao blaggacao May 17, 2021

Choose a reason for hiding this comment

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

Maybe we can be a little more restrictive and require users to set default* in terms of self.packages.${system}.mypackage instead of provide the possibility of a full blown builder, that receives channels attribute. (Same for apps.)

What do you think?

The implication would be that "defaults" specifically depend on "non-defaults", which semantically kind of makes sense anyhow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is generally a good practice. I have no idea how to implement a restriction for that. If we try and check if something is referring to self we would probably run into infinite recursion.

, defaultAppBuilder ? null
, devShellBuilder ? null
, checksBuilder ? null
, outputsBuilder ? channels: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Naming: I really like outputsBuilder. I don't think we should use exports. Any better ideas?

@gytis-ivaskevicius
Copy link
Owner

I don't want to ruin your fun but before bed, I thought to play around with it and I think I got a perfectly working version of this. I Will push in just a bit

@Pacman99
Copy link
Collaborator Author

I don't want to ruin your fun but before bed, I thought to play around with it and I think I got a perfectly working version of this. I Will push in just a bit

Please go ahead, if you want to open a separate PR thats fine too. I got something working, but there still some errors with my version.

@gytis-ivaskevicius
Copy link
Owner

Yeah, I opened a separate one #59
Would have edited this one but this PR is from your fork

I just need to double check CI output, but it should be good

@Pacman99 Pacman99 closed this May 17, 2021
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