Connection refused by demon since nixos-rebuilt, probably other related problems

Since a nixos-rebuild switch --upgrade this morning, I can’t do any nix related commands anymore, that want to talk to the demon without using sudo, which again does it in the wrong context then.

The rebuild was done with --update by accident, I actually wanted just add "btrfs" and "exfat" to boot.filesystems and do a switch with reboot, though I took the wrong command from history…

Already during that rebuild, I messages like this passing by (these are from a subsequent run):

Failed to start basic.target: Unit -.mount is masked.
Failed to start graphical.target: Unit -.mount is masked.
Failed to start local-fs.target: Unit boot.mount is masked.
Failed to start multi-user.target: Unit -.mount is masked.
Failed to start swap.target: Unit -.mount is masked.

Now any sudo nixos-rebuild does print also warnings like these multiple times as well as those from above:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = (unset),
        LANG = "en_DE.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Also my prompt (pwerlevel10k) for zsh isn’t working anymore, though currently I’m not sure if this is related or not.

Not beeing able to connect to the daemon, as well as the “Unit -.mount is masked” went away after a reboot and another rebuild…

Still the warnings because of the locale persist…

locale errors are due to wrong $LOCALE_ARCHIVE. What is it set to? Does the archive exists?

Yes it does and permissions seem to be fine.

$ printenv LOCALE_ARCHIVE
/run/current-system/sw/lib/locale/locale-archive
$ stat /run/current-system/sw/lib/locale/locale-archive
  File: /run/current-system/sw/lib/locale/locale-archive
  Size: 128690032       Blocks: 251549     IO Block: 131072 regular file
Device: 1ah/26d Inode: 10343       Links: 2
Access: (0444/-r--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-02-07 00:08:23.826846694 +0100
Modify: 1970-01-01 01:00:01.000000000 +0100
Change: 2020-02-07 00:40:55.855517232 +0100
 Birth: -

edit:

I followed the link:

stat $(readlink -f $(printenv LOCALE_ARCHIVE))
  File: /nix/store/nl67flma20ixa0x5jms4wk0yfbx4c9wb-glibc-locales-2.27/lib/locale/locale-archive
  Size: 128690032       Blocks: 251549     IO Block: 131072 regular file
Device: 1ah/26d Inode: 10343       Links: 2
Access: (0444/-r--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-02-07 00:08:23.826846694 +0100
Modify: 1970-01-01 01:00:01.000000000 +0100
Change: 2020-02-07 00:40:55.855517232 +0100
 Birth: -

Additional observation:

After I set LANG=en_US.UTF-8, then I won’t see any local related warnings anymore in the current shell session, also my prompt does work in that session.

Related section from /etc/nixos/configuration.nix:

i18n = {
  consoleFont = "Lat2-Terminus16";
  consoleKeyMap = "de";
  defaultLocale = "en_US.UTF-8";
};