all repos — nixfiles @ 03243f3c327adcb300543d73355dd9ceca57ffb8

System and user configuration, managed by nix and home-manager

system/roles/oci.nix (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
  config,
  ...
}:
let
  net = {
    gateway = "10.13.0.1";
    subnet = "10.13.0.0/16";
  };
in
{
  virtualisation.podman = {
    autoPrune = {
      enable = true;
    };
    defaultNetwork.settings = {
      ipv6_enabled = true;
      dns_enabled = true;
      subnets = [
        net
      ];
    };
  };

  virtualisation.containers.containersConf = {
    settings = {
      network = {
        default_subnet = net.subnet;
      };
    };
  };

  services.resolved.dnsDelegates.podman = {
    Delegate = {
      DNS = net.gateway;
      Domains = [ "dns.podman" ];
    };
  };

  assertions = [
    {
      assertion =
        (config.virtualisation.podman.defaultNetwork.settings.dns_enabled && config.services.dnsmasq.enable)
        -> config.services.dnsmasq.settings.bind-interfaces != true;
      message = "Need to use bind-interfaces in dnsmasq when using dns in a podman network";
    }
  ];
}