The restartUnits option does not work for systemd user services
The sops.secrets."secret".restartUnits or sops.templates."template".restartUnits does not restart the configured service if it's a Systemd user service.
Example:
{config, pkgs, ...}:
{
environment.systemPackages = [
pkgs.dufs
];
sops = {
secrets = {
"webdav_username" = {
key = "username";
sopsFile = ./secrets/webdav.yaml;
};
"webdav_password" = {
key = "password";
sopsFile = ./secrets/webdav.yaml;
};
};
templates = {
"webdav-dufs.yaml" = {
content = ''
serve-path: '/mnt/storage'
bind: 127.0.0.1
port: 6065
hidden:
- '.*' # hidden dotfiles
- '*.lock' # hidden extensions
auth:
- ${config.sops.placeholder.webdav_username}:${config.sops.placeholder.webdav_password}@/:rw
allow-all: true
enable-cors: true
render-index: true
render-try-index: true
render-spa: true
compress: low
'';
owner = "geza";
restartUnits = [ "webdav.service" ];
};
};
};
systemd.user.services."webdav" = {
after = [ "network.target" ];
description = "Serve /mnt/storage over WebDav";
serviceConfig = {
ExecStart = "${pkgs.dufs}/bin/dufs --config ${config.sops.templates."webdav-dufs.yaml".path}";
Type = "exec";
};
wantedBy = [ "multi-user.target" "default.target" ];
};
};
Applying the configuration:
activating the configuration... setting up /etc... sops-install-secrets: Imported /etc/ssh/ssh_host_rsa_key as GPG key with fingerprint a444e7a98b1d39cd1427a48064a4470b55d05ed9 sops-install-secrets: Imported /etc/ssh/ssh_host_ed25519_key as age key with fingerprint age1hss0xnkj03sgdrdra39dgdp6h5dtf0gldpnfye6ctjg8yyesj54s2awnxt modifying secret: webdav_username modifying rendered secret: webdav-dufs.yaml reloading user units for geza... restarting sysinit-reactivation.target starting the following units: webdav.service Failed to start webdav.service: Unit webdav.service not found. warning: error(s) occurred while switching to the new configuration
Is my config incorrect or it's not supported?
That is currently not supported. I would recommend to add a reatartTriggers to the systemd unit itself.