1 { config, lib, pkgs, ... }:
3 cfg = config.virtualisation.containers;
5 inherit (lib) literalExpression mkOption types;
7 toml = pkgs.formats.toml { };
11 maintainers = [ ] ++ lib.teams.podman.members;
14 options.virtualisation.containers = {
21 This option enables the common /etc/containers configuration module.
25 ociSeccompBpfHook.enable = mkOption {
28 description = "Enable the OCI seccomp BPF hook";
31 containersConf.settings = mkOption {
34 description = "containers.conf configuration";
37 containersConf.cniPlugins = mkOption {
38 type = types.listOf types.package;
39 defaultText = literalExpression ''
44 example = literalExpression ''
46 pkgs.cniPlugins.dnsname
50 CNI plugins to install on the system.
54 storage.settings = mkOption {
56 description = "storage.conf configuration";
61 type = types.listOf types.str;
62 default = [ "docker.io" "quay.io" ];
64 List of repositories to search.
70 type = types.listOf types.str;
72 List of insecure repositories.
78 type = types.listOf types.str;
80 List of blocked repositories.
88 example = literalExpression ''
90 default = [ { type = "insecureAcceptAnything"; } ];
93 "" = [ { type = "insecureAcceptAnything"; } ];
99 Signature verification policy file.
100 If this option is empty the default policy file from
101 `skopeo` will be used.
107 config = lib.mkIf cfg.enable {
109 virtualisation.containers.containersConf.cniPlugins = [ pkgs.cni-plugins ];
111 virtualisation.containers.containersConf.settings = {
112 network.cni_plugin_dirs = map (p: "${lib.getBin p}/bin") cfg.containersConf.cniPlugins;
114 init_path = "${pkgs.catatonit}/bin/catatonit";
115 } // lib.optionalAttrs cfg.ociSeccompBpfHook.enable {
116 hooks_dir = [ config.boot.kernelPackages.oci-seccomp-bpf-hook ];
120 virtualisation.containers.storage.settings.storage = {
121 driver = lib.mkDefault "overlay";
122 graphroot = lib.mkDefault "/var/lib/containers/storage";
123 runroot = lib.mkDefault "/run/containers/storage";
127 "containers/containers.conf".source =
128 toml.generate "containers.conf" cfg.containersConf.settings;
130 "containers/storage.conf".source =
131 toml.generate "storage.conf" cfg.storage.settings;
133 "containers/registries.conf".source = toml.generate "registries.conf" {
134 registries = lib.mapAttrs (n: v: { registries = v; }) cfg.registries;
137 "containers/policy.json".source =
138 if cfg.policy != { } then pkgs.writeText "policy.json" (builtins.toJSON cfg.policy)
139 else "${pkgs.skopeo.policy}/default-policy.json";