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

Add explicit settings for ‘locale’ and ‘locale_archive’ #328

Merged
merged 2 commits into from
Jul 10, 2018

Conversation

mrkkrp
Copy link
Member

@mrkkrp mrkkrp commented Jul 9, 2018

This PR allows to avoid issues related to reading Unicode text files at compile time. Previously, due to unset locale, locale defaulted to ASCII and reading Unicode text was impossible. This prevented use of e.g. Dhall's TH helpers.

@mrkkrp mrkkrp requested review from mboes and judah July 9, 2018 12:48
@Profpatsch
Copy link
Contributor

Note that the default glibc locale package is >20MB in size iirc. It provides a mechanism to create a database with a subset of locales though, like so: https://gitlab.techcultivation.org/sangha/sangha-deployment/blob/master/containers/helpers/gen-utf8-localedb.nix

),
"locale_archive": attr.label(
allow_single_file = True,
doc = "Label pointing to the locale archive file to use.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a note that this is nix-specific, or a link to docs?

@mrkkrp mrkkrp merged commit d867758 into master Jul 10, 2018
@mrkkrp mrkkrp deleted the mk/encoding branch July 10, 2018 02:55
"locale_archive": attr.label(
allow_single_file = True,
doc = """
Label pointing to the locale archive file to use. Mostly useful on NixOS.
Copy link
Member

Choose a reason for hiding this comment

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

So it turns out LOCALE_ARCHIVE is completely nixpkgs specific, not a POSIX thing. They patch glibc to handle that environment variable. Not sure why it's not called NIX_LOCALE_ARCHIVE but whatever. Given this, it's a shame that we're polluting rules_haskell with Nixpkgs specifc hacks. A better fix long term will be to submit a patch so that the ghc derivation in Nixpkgs includes a locale archive in its closure.

@Profpatsch thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I don’t know. That would be for @peti to decide.

According to glibc source code it’s normally fixed at configuration time via the COMPLOCALEDIR option, instead of being a variable path at runtime. I’m not sure why it’s solved with an env var instead of a fix filepath (e.g. /var/lib/locale-archive) in nixpkgs.

Copy link

@peti peti Jul 11, 2018

Choose a reason for hiding this comment

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

I’m not sure why it’s solved with an env var instead of a fix filepath (e.g. /var/lib/locale-archive) in nixpkgs.

That path needs super user privileges to set up and it's system-wide. $LOCALE_ARCHIVE, on the other hand, can be configured on a per-process basis and needs no privileges to set or unset. See NixOS/nixpkgs#38991 for an example why such concerns may be important.

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.

5 participants