How to have a service available, but not started at boot

Could I use the same tricks for other services?

1. `systemd.services.unifi.wantedBy = mkForce [];` should do the trick
3. run it in a container with `autoStart = false;`

I’d like nextcloud to be configured using my nixos-config. But only started after I un-luks and mount the data disk manually. For now I want to use a manual unlock.

Are there other things I’m missing?

Yep, should work too. I’d suggest removing the wantedBy over running stuff in containers to avoid using the module, that’s just silly.

Since you specifically care about something being mounted before your unit starts, you could set a dependency on the mount unit. Then nextcloud won’t start until it is mounted.

2 Likes

Yep, should work too. I’d suggest removing the wantedBy over running stuff in containers to avoid using the module, that’s just silly.

Depends. If you have multiple dependent pieces you want to run for some random thing then a container is by far the easiest way to do it. You could also do something with custom targets, but the container option is cleaner.

Since you specifically care about something being mounted before your unit starts, you could set a dependency on the mount unit. Then nextcloud won’t start until it is mounted.

100 x this. Don’t ever do anything manually repeatedly if you can configure it to happen automatically.

2 Likes