Skip to content

haskell-modules: keep things sorted#401492

Merged
wolfgangwalther merged 5 commits intoNixOS:haskell-updatesfrom
wolfgangwalther:haskell-keep-sorted
May 5, 2025
Merged

haskell-modules: keep things sorted#401492
wolfgangwalther merged 5 commits intoNixOS:haskell-updatesfrom
wolfgangwalther:haskell-keep-sorted

Conversation

@wolfgangwalther
Copy link
Contributor

I suggested to keep things sorted in main.yaml and was nerd-sniped by #400861 (comment).

Commits sorted (!) by potential controversy:

  • Fixing the maintainer scripts to consistently sort "-" correctly and case-insensitively is a no-brainer.
  • We already have a keep-sorted CI workflow, which we can make use of to keep the manually maintained main.yaml in order. I hope we can agree on that.
  • The last commits about configuration-common.nix are kind of an experiment:
    • How much can keep-sorted do? (quite a lot)
    • Does this actually work? (let's see the number of rebuilds, hoping it to be 0)
    • Do we want something like that? You tell me!

When looking at a file like configuration-common.nix, I am always wondering: "OK, and where do I put my new stuff now?". This makes it 100% clear.

Things done


Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: haskell General-purpose, statically typed, purely functional programming language label Apr 24, 2025
@nix-owners nix-owners bot requested review from maralorn and sternenseemann April 24, 2025 16:43
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Apr 24, 2025
@maralorn
Copy link
Member

maralorn commented May 4, 2025

I think I am generally in favor.

My main concern is with the locale config. I don’t know how to do this right and this might be the right way, but I remember that we had a lot of portability issues with that stuff. It is unclear to me whether there is any locale which we can reliably expect to exist on all devs systems. But apparently we already use C.UTF-8 at one place so using it everywhere does not seem worse.

Re: Sorting configuration-common.nix

I would argue that if we want to enforce sorting in a human edited file then we need CI to enforce it. What command did you use to do the sorting?

Our previous approach was: add at random position to avoid merge conflicts as much as possible. But sorting alphabetically achieves a similar goal. Main disadvantage I see is that sometimes it makes sense to sort packages topically and of course enforcing it in CI will annoy people.

@wolfgangwalther
Copy link
Contributor Author

It is unclear to me whether there is any locale which we can reliably expect to exist on all devs systems. But apparently we already use C.UTF-8 at one place so using it everywhere does not seem worse.

C.UTF-8 is exactly the one "locale" we can rely on. Just C would be even more reliable, but I guess C.UTF-8 is enough nowadays.

I would argue that if we want to enforce sorting in a human edited file then we need CI to enforce it. What command did you use to do the sorting?

CI already enforces it! It's the "keep-sorted" workflow: https://github.com/NixOS/nixpkgs/actions/runs/14646951951/job/41103466827?pr=401492

To run it locally, just do nix-shell -p keep-sorted and then keep-sorted <path>. It will sort automatically according to the configuration comment.

Our previous approach was: add at random position to avoid merge conflicts as much as possible. But sorting alphabetically achieves a similar goal. Main disadvantage I see is that sometimes it makes sense to sort packages topically and of course enforcing it in CI will annoy people.

Yeah, the upside isn't that big. If "random position to avoid merge conflicts" is the idea, maybe we should explicitly mention that instead. It is the same approach mentioned in the release notes - and there I sure don't have the problem of figuring out where to put stuff. Aka, as someone who wants to do stuff "right", a comment telling me "hey, put it in a random spot" would 100% help my first interaction with that file.

@maralorn
Copy link
Member

maralorn commented May 4, 2025

Ah, fair enough. Cool.

I am on-the-fence regarding sorting configuration-common.nix.

Pro:

  • reduced conceptual overload, especially when new to the file
  • slightly easier navigation (nearly moot point in the face of control+f
  • sorting might sometimes lead you to find neighboring relevant overrides. First you detect whether there already is an override (which is nearly useless because you will get a nix error, second you find similar named packages, especially versioned overrides for the same package. The last one is the biggest win in my opinion.
  • enforced sorting avoids merge conflicts caused by people not respecting the random spot rule.

Con:

  • commenting the random approach is easy
  • sorting errors increase CI roundtrips

I have really no strong opinion. I like the last two pro arguments, but in the end I fear it is just more bureaucracy.

@wolfgangwalther
Copy link
Contributor Author

One more Con:

  • The attributes added with inherit (...) ...; are not sorted by their attribute name, but by "inherit".

So the sorting is still a bit inconsistent in the end.

@wolfgangwalther
Copy link
Contributor Author

Since the step of sorting this is potentially introducing merge conflicts on it's own, I'll drop that commit and add a note about the preferred random position to the file's header.

@wegank wegank added 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. 12.approvals: 1 This PR was reviewed and approved by one person. labels May 4, 2025
…istently

sort -i actually means "ignore nonprinting", not "ignore case". Also, we
need to set LC_ALL to get proper sorting for "-".
…n.yaml

We have keep-sorted as a CI job for a while, so we can make use of it.
Some outdated comments removed, otherwise moved above their related
line.
@wolfgangwalther wolfgangwalther merged commit 12d8b0e into NixOS:haskell-updates May 5, 2025
21 of 28 checks passed
@wolfgangwalther wolfgangwalther deleted the haskell-keep-sorted branch May 5, 2025 20:20
Comment on lines -786 to -788
kmonad: [ platforms.darwin ]

supported-platforms:
Copy link
Contributor Author

@wolfgangwalther wolfgangwalther May 10, 2025

Choose a reason for hiding this comment

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

Thanks for fixing the missing keep-sorted annotations here in 58c2619, @sternenseemann. I guess I was too focused on the rebuilds and confirming the changes in configuration-common.nix not causing changes (which we later removed again). Should have regenerated the hackage set instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: haskell General-purpose, statically typed, purely functional programming language 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants