How to set a system wide umask value for all users?

I would like to set the sytem wide umask value so that all users are affected without having to set the umask value in ~/.bashrc for each user. I read that this can be set in /etc/profile and /etc/bashrc but both files have warnings not to edit them.

How can i properly set a umask value for all my users in NIxos declaratively?

Is environment.extraInit = "umask 0077"; the proper way to do it or does it have unintended side-effects?

Like on any other Linux distribution with the exception that you don’t write it into /etc or so but into the config.

I am guessing this would be done via pam but I am not sure.

This was actually something I stumbled upon when I was new to Nix. I used to do this in my old distro by changing the /etc/login.defs file, as it allows setting umask. I asked a question here on same topic for reference

I saw that thread, thank you. But the outcome was inconclusive to me.

Setting environment.extraInit = "umask 0077"; seems to work for me so if that has no downsides i’m happy with that.