From 9fe5709976a6e820a2a48c04a41fb84da9dd9eaa Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 4 Apr 2021 23:03:25 +0200 Subject: [PATCH] lxc-containers: add experimental lxc-reload on system change --- nix/nixos-module/server/lxc-containers.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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"; + }; }