How can I create configuration files for a user before they log in?

And no, I do not want to use home-manager. I just want to create 2-3 basic and shot config files like .zshrc or .vimrc. I don’t want to pull in all of home-manager just to create a few files. Is there a way to do that?

Or would I have to write some kind of Systemd service running a script that would do that for me at first login or something like that?

Have you considered using either skeleton files which is a common concept on linuxes?

Or alternatively using the activation script to create the files? As far as I remember there is an option available that allows you to extend the activation script.

1 Like

For every user? If so then security.pam.makeHomeDir.skelDirectory is probably what you want.

If not… any more details?

2 Likes

Oh, I wasn’t aware this was exposed in Nix. Thank you, this seems like the perfect solution for me.

I assume I can create the value for skelDirectory from a derivation that would contain the basic configuration. I like that approach, it’s very clean.

I tried googling a bunch but all I ever get for questions about nixos and user configuration is “use home-manager”, but that just seems like a massive overkill just for some basic user configuration.

That’s interesting. That’s more tangentially related to my OP question, but what option handles this activation script? For my personal user I keep dotfiles in a separate repo and just symlink them with a simple bash script when NixOS installation is done, but an activation script would be nice.

Are you referring to this?
https://search.nixos.org/options?channel=20.09&query=system.userActivationScripts