diff --git a/nix/nixos-module/server/lxc-containers.nix b/nix/nixos-module/server/lxc-containers.nix index 385c609..00c4cb8 100644 --- a/nix/nixos-module/server/lxc-containers.nix +++ b/nix/nixos-module/server/lxc-containers.nix @@ -170,7 +170,19 @@ in systemd.targets.lxc-containers = { wantedBy = [ "multi-user.target" ]; - wants = map (ctName: "lxc@${ctName}.service") + wants = builtins.concatMap (ctName: [ "lxc@${ctName}.service" "lxc-reload@${ctName}.path" ]) (builtins.attrNames containers); }; + + systemd.paths."lxc-reload@" = { + pathConfig = { + PathChanged = "/var/lib/lxc/%i/rootfs/init"; + }; + }; + systemd.services."lxc-reload@" = { + requires = [ "lxc@%i.service" ]; + serviceConfig.Type = "oneshot"; + scriptArgs = "%i"; + script = "/run/current-system/systemd/bin/systemctl reload lxc@$1.service || true"; + }; }