nixos/containers: move extraConfig to settings model
This commit is contained in:
parent
cf42b2eb0f
commit
7c36ce8d3a
@ -4,15 +4,7 @@ let
|
|||||||
|
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
|
|
||||||
# Once https://github.com/NixOS/nixpkgs/pull/75584 is merged we can use the TOML generator
|
toml = pkgs.formats.toml { };
|
||||||
toTOML = name: value: pkgs.runCommandNoCC name {
|
|
||||||
nativeBuildInputs = [ pkgs.remarshal ];
|
|
||||||
value = builtins.toJSON value;
|
|
||||||
passAsFile = [ "value" ];
|
|
||||||
} ''
|
|
||||||
json2toml "$valuePath" "$out"
|
|
||||||
'';
|
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
meta = {
|
meta = {
|
||||||
@ -26,6 +18,11 @@ in
|
|||||||
[ "virtualisation" "containers" "users" ]
|
[ "virtualisation" "containers" "users" ]
|
||||||
"All users with `isNormalUser = true` set now get appropriate subuid/subgid mappings."
|
"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 = {
|
options.virtualisation.containers = {
|
||||||
@ -45,23 +42,10 @@ in
|
|||||||
description = "Enable the OCI seccomp BPF hook";
|
description = "Enable the OCI seccomp BPF hook";
|
||||||
};
|
};
|
||||||
|
|
||||||
containersConf = mkOption {
|
containersConf.settings = mkOption {
|
||||||
default = {};
|
type = toml.type;
|
||||||
|
default = { };
|
||||||
description = "containers.conf configuration";
|
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 = {
|
registries = {
|
||||||
@ -113,21 +97,19 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
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 = ''
|
environment.etc."containers/containers.conf".source =
|
||||||
[network]
|
toml.generate "containers.conf" cfg.containersConf.settings;
|
||||||
cni_plugin_dirs = ["${pkgs.cni-plugins}/bin/"]
|
|
||||||
|
|
||||||
[engine]
|
environment.etc."containers/registries.conf".source = toml.generate "registries.conf" {
|
||||||
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/registries.conf".source = toTOML "registries.conf" {
|
|
||||||
registries = lib.mapAttrs (n: v: { registries = v; }) cfg.registries;
|
registries = lib.mapAttrs (n: v: { registries = v; }) cfg.registries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,13 +96,12 @@ in
|
|||||||
|
|
||||||
virtualisation.containers = {
|
virtualisation.containers = {
|
||||||
enable = true; # Enable common /etc/containers configuration
|
enable = true; # Enable common /etc/containers configuration
|
||||||
containersConf.extraConfig = lib.optionalString cfg.enableNvidia
|
containersConf.settings = lib.optionalAttrs cfg.enableNvidia {
|
||||||
(builtins.readFile (toml.generate "podman.nvidia.containers.conf" {
|
engine = {
|
||||||
engine = {
|
conmon_env_vars = [ "PATH=${lib.makeBinPath [ pkgs.nvidia-podman ]}" ];
|
||||||
conmon_env_vars = [ "PATH=${lib.makeBinPath [ pkgs.nvidia-podman ]}" ];
|
runtimes.nvidia = [ "${pkgs.nvidia-podman}/bin/nvidia-container-runtime" ];
|
||||||
runtimes.nvidia = [ "${pkgs.nvidia-podman}/bin/nvidia-container-runtime" ];
|
};
|
||||||
};
|
};
|
||||||
}));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.packages = [ cfg.package ];
|
systemd.packages = [ cfg.package ];
|
||||||
|
Loading…
Reference in New Issue
Block a user