Hi! I couldn’t find anything related but I’d be interested in a virtualisation.podman.networks option which lets you create podman network declaratively.
Are there any plans for this? Should I give it a try?
Can’t speak to plans/availability within NixOS proper, but I swapped to GitHub - SEIAROTg/quadlet-nix: Manages Podman containers and networks on NixOS via Quadlet. · GitHub a while back which supports this feature if you’re just looking to get something working. It relies on podman-quadlet — Podman documentation which dovetail nicely into systemd services and let you declare all sorts of podman resources declaratively.
I think it would be a nice module option, it is a feature that would likely improve QoL especially given that it would complement virtualisation.oci-containers.containers.<>.networks well. You might want to ask the maintainers of the module (@sascha, @vdemeester) also though.
For most of my stuff I usually just set up a small systemd service instead that runs before the service for the container(s), e.g.,
systemd.services.ism-container-network = {
enable = true;
wantedBy = [ "multi-user.target" ];
before = [ "${config.virtualisation.oci-containers.containers.ism-api.serviceName}.service" ];
serviceConfig.Restart = lib.mkForce "no";
serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true;
path = [ config.virtualisation.podman.package ];
script = ''
if ! podman inspect ism-net; then
podman network create ism-net
fi
'';
};