How to set LOCALE_ARCHIVE environment variable properly on nixos?

I had some issue trying to run a program. It gave hGetContents: invalid argument error. After googling around I came acroos
the following thread.

Looking at the thread it seems the issue is related to the value of LOCALE_CACHE environment variable. The thread links to a manual page that provides the solution for nixpkgs on Non-NixOS platform. NixOS wiki has a page on the topic which agains only shows the solution for Non-NixOS platforms.

Looking around the options in nixos, I came across i18n.glibcLocales and tried setting i18n.glibcLocales = pkgs.glibcLocales. Unfortunately it didn’t solve the issue.

This is how I deal with it in BEAM related Dev shells.

I wouldn’t set that variable system wide though.

Thanks for the solution.

The problem was due to me trying to directly run the binary provided by the repo. :stuck_out_tongue:
Recompiling the library locally using cabal2nix fixes the issue without the need of setting any variables.