modules(pihole-container): expliclitly stop the container with podman
Currently the container often fails to startup again in a nixos-rebuild. Maybe this is because the container lingers a bit after the systemd.service has already been stopped and the container from the restarted service can't be created. The podman-stop command should delay the stopping of the service until the container is gone too.
This commit is contained in:
parent
dde81d1e16
commit
d523a5c8e1
1 changed files with 12 additions and 1 deletions
|
@ -58,6 +58,14 @@ in rec {
|
|||
'';
|
||||
};
|
||||
|
||||
containerName = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
The name of the podman container in which pihole will be started.
|
||||
'';
|
||||
default = "pihole_${cfg.hostConfig.user}";
|
||||
};
|
||||
|
||||
persistVolumes = mkOption {
|
||||
type = types.bool;
|
||||
description = "Whether to use podman volumes to persist pihole's ad-hoc configuration across restarts.";
|
||||
|
@ -316,7 +324,7 @@ in rec {
|
|||
${pkgs.podman}/bin/podman run \
|
||||
--rm \
|
||||
--rmi \
|
||||
--name="pihole_${cfg.hostConfig.user}" \
|
||||
--name="${cfg.hostConfig.containerName}" \
|
||||
${
|
||||
if cfg.hostConfig.persistVolumes then ''
|
||||
-v ${cfg.hostConfig.volumesPath}/etc-pihole:/etc/pihole \
|
||||
|
@ -332,6 +340,9 @@ in rec {
|
|||
} \
|
||||
docker-archive:${piholeFlake.packages.${pkgs.system}.piholeImage}
|
||||
'';
|
||||
ExecStop = ''
|
||||
${pkgs.podman}/bin/podman stop ${cfg.hostConfig.containerName}
|
||||
'';
|
||||
#TODO check that user can control podman & has subuidmap/subgidmap set
|
||||
User = "${cfg.hostConfig.user}";
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue