chore: split nixos and opentofu
This commit is contained in:
parent
d125848b82
commit
06500a8f01
68 changed files with 44 additions and 61 deletions
|
|
@ -1,38 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
options.homelab.dockerNetworks = lib.mkOption {
|
||||
description = "Declarative Docker networks to create before containers start.";
|
||||
default = {};
|
||||
type = lib.types.attrsOf (lib.types.submodule {
|
||||
options = {
|
||||
requiredBy = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [];
|
||||
description = "List of systemd services that require this network (e.g., docker-containerName.service).";
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
config = {
|
||||
systemd.services = lib.mapAttrs' (networkName: cfg:
|
||||
lib.nameValuePair "docker-${networkName}-create-network" {
|
||||
description = "Create Docker network for ${networkName}";
|
||||
requiredBy = cfg.requiredBy;
|
||||
after = [ "network.target" "docker.service" ];
|
||||
requires = [ "docker.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = pkgs.writeShellScript "create-${networkName}-docker-network" ''
|
||||
if ! ${pkgs.docker}/bin/docker network ls | grep -q ${networkName}; then
|
||||
${pkgs.docker}/bin/docker network create ${networkName}
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
) config.homelab.dockerNetworks;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue