2020-09-25 04:45:31 +00:00
|
|
|
{ config, lib, pkgs, utils, ... }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.virtualisation.cri-o;
|
2020-05-15 21:57:56 +00:00
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
crioPackage = (pkgs.cri-o.override { inherit (cfg) extraPackages; });
|
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
format = pkgs.formats.toml { };
|
|
|
|
|
|
|
|
cfgFile = format.generate "00-default.conf" cfg.settings;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "virtualisation" "cri-o" "registries" ] [ "virtualisation" "containers" "registries" "search" ])
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = {
|
2021-07-21 07:28:18 +00:00
|
|
|
maintainers = teams.podman.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
options.virtualisation.cri-o = {
|
|
|
|
enable = mkEnableOption "Container Runtime Interface for OCI (CRI-O)";
|
|
|
|
|
|
|
|
storageDriver = mkOption {
|
2020-05-29 06:06:01 +00:00
|
|
|
type = types.enum [ "btrfs" "overlay" "vfs" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "overlay";
|
|
|
|
description = "Storage driver to be used";
|
|
|
|
};
|
|
|
|
|
|
|
|
logLevel = mkOption {
|
2020-05-29 06:06:01 +00:00
|
|
|
type = types.enum [ "trace" "debug" "info" "warn" "error" "fatal" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "info";
|
|
|
|
description = "Log level to be used";
|
|
|
|
};
|
|
|
|
|
|
|
|
pauseImage = mkOption {
|
2020-05-29 06:06:01 +00:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = "Override the default pause image for pod sandboxes";
|
2021-10-06 13:57:05 +00:00
|
|
|
example = "k8s.gcr.io/pause:3.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pauseCommand = mkOption {
|
2020-05-29 06:06:01 +00:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = "Override the default pause command";
|
2021-10-06 13:57:05 +00:00
|
|
|
example = "/pause";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
runtime = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = "Override the default runtime";
|
2021-10-06 13:57:05 +00:00
|
|
|
example = "crun";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [ ];
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2020-05-29 06:06:01 +00:00
|
|
|
[
|
|
|
|
pkgs.gvisor
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages to be installed in the CRI-O wrapper.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
package = mkOption {
|
2020-05-29 06:06:01 +00:00
|
|
|
type = types.package;
|
|
|
|
default = crioPackage;
|
2021-12-19 01:06:50 +00:00
|
|
|
defaultText = literalDocBook ''
|
|
|
|
<literal>pkgs.cri-o</literal> built with
|
|
|
|
<literal>config.${opt.extraPackages}</literal>.
|
|
|
|
'';
|
2020-05-29 06:06:01 +00:00
|
|
|
internal = true;
|
|
|
|
description = ''
|
|
|
|
The final CRI-O package (including extra packages).
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2020-09-25 04:45:31 +00:00
|
|
|
|
|
|
|
networkDir = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
description = "Override the network_dir option.";
|
|
|
|
internal = true;
|
|
|
|
};
|
2021-07-21 07:28:18 +00:00
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = format.type;
|
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
Configuration for cri-o, see
|
|
|
|
<link xlink:href="https://github.com/cri-o/cri-o/blob/master/docs/crio.conf.5.md"/>.
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2020-05-29 06:06:01 +00:00
|
|
|
environment.systemPackages = [ cfg.package pkgs.cri-tools ];
|
2020-05-15 21:57:56 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
environment.etc."crictl.yaml".source = utils.copyFile "${pkgs.cri-o-unwrapped.src}/crictl.yaml";
|
2020-05-15 21:57:56 +00:00
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
virtualisation.cri-o.settings.crio = {
|
|
|
|
storage_driver = cfg.storageDriver;
|
|
|
|
|
|
|
|
image = {
|
|
|
|
pause_image = mkIf (cfg.pauseImage != null) cfg.pauseImage;
|
|
|
|
pause_command = mkIf (cfg.pauseCommand != null) cfg.pauseCommand;
|
|
|
|
};
|
|
|
|
|
|
|
|
network = {
|
|
|
|
plugin_dirs = [ "${pkgs.cni-plugins}/bin" ];
|
|
|
|
network_dir = mkIf (cfg.networkDir != null) cfg.networkDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
runtime = {
|
|
|
|
cgroup_manager = "systemd";
|
|
|
|
log_level = cfg.logLevel;
|
|
|
|
manage_ns_lifecycle = true;
|
|
|
|
pinns_path = "${cfg.package}/bin/pinns";
|
|
|
|
hooks_dir =
|
|
|
|
optional (config.virtualisation.containers.ociSeccompBpfHook.enable)
|
|
|
|
config.boot.kernelPackages.oci-seccomp-bpf-hook;
|
|
|
|
|
|
|
|
default_runtime = mkIf (cfg.runtime != null) cfg.runtime;
|
|
|
|
runtimes = mkIf (cfg.runtime != null) {
|
|
|
|
"${cfg.runtime}" = { };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
environment.etc."cni/net.d/10-crio-bridge.conf".source = utils.copyFile "${pkgs.cri-o-unwrapped.src}/contrib/cni/10-crio-bridge.conf";
|
|
|
|
environment.etc."cni/net.d/99-loopback.conf".source = utils.copyFile "${pkgs.cri-o-unwrapped.src}/contrib/cni/99-loopback.conf";
|
2021-07-21 07:28:18 +00:00
|
|
|
environment.etc."crio/crio.conf.d/00-default.conf".source = cfgFile;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Enable common /etc/containers configuration
|
|
|
|
virtualisation.containers.enable = true;
|
|
|
|
|
|
|
|
systemd.services.crio = {
|
|
|
|
description = "Container Runtime Interface for OCI (CRI-O)";
|
|
|
|
documentation = [ "https://github.com/cri-o/cri-o" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
2020-05-29 06:06:01 +00:00
|
|
|
path = [ cfg.package ];
|
2020-04-24 23:36:52 +00:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "notify";
|
2020-05-29 06:06:01 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/crio";
|
2020-04-24 23:36:52 +00:00
|
|
|
ExecReload = "/bin/kill -s HUP $MAINPID";
|
|
|
|
TasksMax = "infinity";
|
|
|
|
LimitNOFILE = "1048576";
|
|
|
|
LimitNPROC = "1048576";
|
|
|
|
LimitCORE = "infinity";
|
|
|
|
OOMScoreAdjust = "-999";
|
|
|
|
TimeoutStartSec = "0";
|
|
|
|
Restart = "on-abnormal";
|
|
|
|
};
|
2021-07-21 07:28:18 +00:00
|
|
|
restartTriggers = [ cfgFile ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|