Run arbitrary commands during rebuild?

HI all,

I’m trying to get my config working so that it will clone down my dotfiles git repo during the system rebuild process. The most likely option I’ve found so far is system.userActivationScripts, but I haven’t been able to get it to work.

Here is a link to my current config: nixos/configuration.nix at b13a60c9e8bb0cec6b4a0908413bf165b77a4965 · sa7mon/nixos · GitHub

Right now, when I do a nixos-rebuild switch, the git clone just never happens.

Any advice would be much appreciated!

Have you tried just activationScripts? I use that to run commands. I have yet to try userActivationScripts.

I did try activationScripts, yes. I get the following error:

The unique option 'system.activationScripts.stdio' is defined multiple times...

I’m defining it in my configuration.nix, and then it’s already in /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/activation/activation-script.nix.
(I would copy-paste the whole thing here but I’m still working on getting copy/paste working in Hyper-V)

If possible, could you provide an example of how you’re doing it?

Have you tried changing the studio part to a different name? sounds like that one is already used somewhere. Unfortunately my use of it isn’t very straightforward - I use it with home-manager-like library I made for writing files to various places.

This is definitely not what activation scripts are for. They’re for quickly configuring critical system components. Look into home-manager and fetchGit.