Home-manager: Rofi installed by home-manager can't set locale

Created on 24 Aug 2018  路  8Comments  路  Source: nix-community/home-manager

Maybe it's that I don't quite understand how nixos and home-manager are meant to interact, but when I have rofi in my configuration.nix, it works fine, since I'm guessing it uses the system-level LOCALE_ARCHIVE environment variable. But when I enable rofi in home-manager, it installs a new copy of rofi, which apparently can't see (or set?) the system-level LOCALE_ARCHIVE, which on my system is /run/current-system/sw/lib/locale/locale-archive, so it fails with:

(process:12909): Rofi-WARNING **: Failed to set locale.

I'm guessing this also has something to do with glibc-locales versions. See, for instance, this nixos issue.

My workaround, following these other bug reports, is to install glibc-locales to my profile with nix-env -iA nixpkgs.glibc-locales, then run Rofi with that path for LOCALE_ARCHIVE, i.e. env LOCALE_ARCHIVE=$HOME/.nix-profile/lib/locale/locale-archive rofi -show drun.

This is kind of an ugly hack. I'm not sure whether this is a bug, or whether I'm doing something wrong, but it'd be nice for programs installed with home-manager to figure out where the locales they need are. Or maybe have home-manager handle the configuration of Rofi, but detect that it's already installed on the system, and not install a new copy?

Version info:

  • ~nix-env -q: glibc-locales-2.26-131~
  • ~nix-info: system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.0.4, channels(root): "nixos-18.09pre149415.8395f9aa85e", channels(jon): "nixpkgs-18.03.133086.c1ef96ebdbd", nixpkgs: /home/jon/.nix-defexpr/channels/nixpkgsw~
  • nix-info: system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.0.4, channels(root): "nixos", nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Edit: debugged some channel problems, hoping that would fix it. Still can't start Rofi; same error.

Most helpful comment

Indeed, doing this at the command line fixes rofi:

export LOCALE_ARCHIVE=$(nix-build '<nixpkgs>' -A glibcLocales)/lib/locale/locale-archive

or, to make it permanent via home-manager:

home.sessionVariables.LOCALES_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";

All 8 comments

I have no idea what I'm doing, but could it just be a matter of adding pkgs.glibcLocales to the list of dependencies of rofi in the home-manager module? (I.e. at https://github.com/rycee/home-manager/blob/master/modules/programs/rofi.nix#L306 ?)

Hmm, yeah I can imagine this being quite annoying. I'm not sure forcing the installation of this on everybody would be a good work-around, though.

It does seem like an issue that is best fixed in Nixpkgs because I assume the same problem would arise if you did nix-env -f '<nixpkgs>' -iA rofi (which is essentially the command Home Manager runs for you to install the package).

I'll have a think about it.

running into this same problem on Debian with home-manager master and Nix 18.09, adding pkgs.glibcLocales to my list of home-manager packages does not seem to fix anything. Does anyone know of a workaround?

Indeed, doing this at the command line fixes rofi:

export LOCALE_ARCHIVE=$(nix-build '<nixpkgs>' -A glibcLocales)/lib/locale/locale-archive

or, to make it permanent via home-manager:

home.sessionVariables.LOCALES_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";

I ran into similar locale issues and found https://gist.github.com/peti/2c818d6cb49b0b0f2fd7c300f8386bc3 which has steps for both nixos and non-nixos.

I believe home-manager should error when user set home.language.base = "en-US.UTF-8"; (this should be en_US.UTF-8) but the locale is not built in nix (default is "C" and "POSIX"). That broke my locale configuration and chinese text display and also others applications that require utf-8.

Only env LANG=C.UTF-8 man man works without warnings and any other locales from system such as en_US.UTF-8 or zh_CN.UTF-8 is broken for man pages, it won't even display zh_CN man pages now. This may be related to this issue I guess?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loewenheim picture loewenheim  路  7Comments

btomasini picture btomasini  路  4Comments

lovesegfault picture lovesegfault  路  6Comments

pmiddend picture pmiddend  路  3Comments

balsoft picture balsoft  路  7Comments