21 lines
708 B
Nix
21 lines
708 B
Nix
{config, ...}: {
|
|
systemd.services.init-traefik-net-bridge-network = {
|
|
description = "Create the network bridge traefik-net for the Docker stack.";
|
|
after = ["network.target"];
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
script = let
|
|
dockercli = "${config.virtualisation.docker.package}/bin/docker";
|
|
in ''
|
|
# Put a true at the end to prevent getting non-zero return code, which will
|
|
# crash the whole service.
|
|
check=$(${dockercli} network ls | grep "traefik-net" || true)
|
|
if [ -z "$check" ]; then
|
|
${dockercli} network create traefik-net
|
|
else
|
|
echo "traefik-net already exists in docker"
|
|
fi
|
|
'';
|
|
};
|
|
}
|