diff options
author | Phillip Cloud <cloud@standard.ai> | 2021-04-03 10:09:40 -0400 |
---|---|---|
committer | Phillip Cloud <cloud@standard.ai> | 2021-04-07 16:08:18 -0400 |
commit | 7c36ce8d3a9460aa59449f11fe60bba13ea4d222 (patch) | |
tree | 4d67b5cfcf415a9f880400ff1d615ee5d01d4bb9 /nixos/modules/virtualisation/containers.nix | |
parent | cf42b2eb0f8e2b7b22b1257c0a2d7a2f6ea1f87c (diff) | |
download | nixpkgs-7c36ce8d3a9460aa59449f11fe60bba13ea4d222.tar nixpkgs-7c36ce8d3a9460aa59449f11fe60bba13ea4d222.tar.gz nixpkgs-7c36ce8d3a9460aa59449f11fe60bba13ea4d222.tar.bz2 nixpkgs-7c36ce8d3a9460aa59449f11fe60bba13ea4d222.tar.lz nixpkgs-7c36ce8d3a9460aa59449f11fe60bba13ea4d222.tar.xz nixpkgs-7c36ce8d3a9460aa59449f11fe60bba13ea4d222.tar.zst nixpkgs-7c36ce8d3a9460aa59449f11fe60bba13ea4d222.zip |
nixos/containers: move extraConfig to settings model
Diffstat (limited to 'nixos/modules/virtualisation/containers.nix')
-rw-r--r-- | nixos/modules/virtualisation/containers.nix | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index 148d0221998..3974caf2233 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -4,15 +4,7 @@ let inherit (lib) mkOption types; - # Once https://github.com/NixOS/nixpkgs/pull/75584 is merged we can use the TOML generator - toTOML = name: value: pkgs.runCommandNoCC name { - nativeBuildInputs = [ pkgs.remarshal ]; - value = builtins.toJSON value; - passAsFile = [ "value" ]; - } '' - json2toml "$valuePath" "$out" - ''; - + toml = pkgs.formats.toml { }; in { meta = { @@ -26,6 +18,11 @@ in [ "virtualisation" "containers" "users" ] "All users with `isNormalUser = true` set now get appropriate subuid/subgid mappings." ) + ( + lib.mkRemovedOptionModule + [ "virtualisation" "containers" "containersConf" "extraConfig" ] + "Use virtualisation.containers.containersConf.settings instead." + ) ]; options.virtualisation.containers = { @@ -45,23 +42,10 @@ in description = "Enable the OCI seccomp BPF hook"; }; - containersConf = mkOption { - default = {}; + containersConf.settings = mkOption { + type = toml.type; + default = { }; description = "containers.conf configuration"; - type = types.submodule { - options = { - - extraConfig = mkOption { - type = types.lines; - default = ""; - description = '' - Extra configuration that should be put in the containers.conf - configuration file - ''; - - }; - }; - }; }; registries = { @@ -113,21 +97,19 @@ in }; config = lib.mkIf cfg.enable { + virtualisation.containers.containersConf.settings = { + network.cni_plugin_dirs = [ "${pkgs.cni-plugins}/bin/" ]; + engine = { + init_path = "${pkgs.catatonit}/bin/catatonit"; + } // lib.optionalAttrs cfg.ociSeccompBpfHook.enable { + hooks_dir = [ config.boot.kernelPackages.oci-seccomp-bpf-hook ]; + }; + }; - environment.etc."containers/containers.conf".text = '' - [network] - cni_plugin_dirs = ["${pkgs.cni-plugins}/bin/"] - - [engine] - init_path = "${pkgs.catatonit}/bin/catatonit" - ${lib.optionalString (cfg.ociSeccompBpfHook.enable) '' - hooks_dir = [ - "${config.boot.kernelPackages.oci-seccomp-bpf-hook}", - ] - ''} - '' + cfg.containersConf.extraConfig; + environment.etc."containers/containers.conf".source = + toml.generate "containers.conf" cfg.containersConf.settings; - environment.etc."containers/registries.conf".source = toTOML "registries.conf" { + environment.etc."containers/registries.conf".source = toml.generate "registries.conf" { registries = lib.mapAttrs (n: v: { registries = v; }) cfg.registries; }; |