Missing locales in cronjob

In cronjobs, the locale is wrong:

  • The locale is set to POSIX instead of the configured defaultLocale
  • Only locales C and POSIX are available, and all others are missing.

How can this be fixed? And is this a known bug?

Details:

  • /etc/nixos/configuration.nix: defaultLocale = "en_DK.UTF-8";

  • $ locale -a:

    C
    de_DE.utf8
    en_DK.utf8
    en_GB.utf8
    en_US.utf8
    POSIX
    
  • but when I run locale -a in a cronjob, I get:

    C
    POSIX
    
2 Likes

Hitting this as well, so still a thing on 22.11
Also see Cron: locale to en_US.UTF-8 ... failed · Issue #48642 · NixOS/nixpkgs · GitHub