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 hackage2nix locale independent #616

Merged
merged 2 commits into from
Feb 5, 2024
Merged

Make hackage2nix locale independent #616

merged 2 commits into from
Feb 5, 2024

Conversation

maralorn
Copy link
Member

Since my system is currently missing the locale C.UTF-8 which we set in regenerate-hackage-packages.nix I want to make hackage2nix locale independent. The impurity is driving me nuts. Since we all edit the same file with hackage2nix hardcoding the locale makes total sense.

From memory I think the locale can affect two things:

  1. It affects the encoding with which hackage-packages.nix get’s written.
  2. It affects the ordering of entries in hackage-packages.nix

After reading the documentation for base:System.IO I am moderately certain that this change fixes 1.

Regarding 2 I am just confused. From reading the code I think the ordering depends on the Ord instances of PackageName and Version. Those are newtypes which in the end all boil down to the Ord instances of ShortByteString or String or Int or Word64. I haven’t found any indication that any of them is locale dependent, but I might have overlooked something. Or the ordering issue is something completely else? I don’t know.

At least I think setting the locale explicitly this way won’t make things less reproducible.

@maralorn
Copy link
Member Author

maralorn commented Feb 4, 2024

I have tested this with and without "LC_ALL=C.UTF-8" on my system and the hackage-packages.nix file always is the same. (Without the fix in this PR with LC_ALL=C.UTF-8 would just fail.)

I suggest merging this PR and the dropping the LC_ALL line from the script in nixpkgs.

Copy link
Member

@cdepillabout cdepillabout left a comment

Choose a reason for hiding this comment

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

This seems reasonable, thanks!

Might be nice to add a note in the CHANGELOG about this as well?

@maralorn maralorn merged commit 173e8a5 into master Feb 5, 2024
5 checks passed
@maralorn maralorn deleted the localeindependence branch February 5, 2024 22:25
@sternenseemann
Copy link
Member

Does it actually affect the ordering of packages in hackage-packages.nix in practice, did you test that? I seriously doubt that was ever the case. IIRC the locale problems is only an issue due to the usage of sort(1) in the maintainer scripts.

@maralorn
Copy link
Member Author

maralorn commented Feb 6, 2024

Aaaah, yeah. I could not reproduce any change in ordering and I was highly confused because I also couldn’t imagine the Haskell sorting being unstable but I was sure I remembered some sorting problem. It makes total sense that this is about the .yaml files.

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