system.activationScripts after specific systemd service

Hi all

Im running a system.activationScripts but I need to run this script just after a specific systemd service.
Any ideia in how to do it or if even its possible?

system.activationScripts is in stage2 nixpkgs/stage-2-init.sh at cf61d1df816834c86880b1c55df6122bc3a8f49a · NixOS/nixpkgs · GitHub

At the end of stage2, start systemd nixpkgs/stage-2-init.sh at cf61d1df816834c86880b1c55df6122bc3a8f49a · NixOS/nixpkgs · GitHub

I think what you need is systemd.services.<name>.postStart

I did not really understood, sorry.
I was looking fro something like

after = [ "set-hostname.service" ];

But this one does not work in the system.activationScripts

Can you tell me a emxempla in how to implement it?

@mlyxshi is saying that system.activationScripts runs before systemd even starts, so it fundamentally cannot be ordered after a systemd service. It’s not just a matter of the option not being present. It doesn’t even make sense.

Is there any reason you can’t use a systemd oneshot service for what you want to do here?

4 Likes