1 { config, lib, pkgs, ... }:
5 cfg = config.virtualisation.cri-o;
7 crioPackage = pkgs.cri-o.override {
8 extraPackages = cfg.extraPackages
9 ++ lib.optional (config.boot.supportedFilesystems.zfs or false) config.boot.zfs.package;
12 format = pkgs.formats.toml { };
14 cfgFile = format.generate "00-default.conf" cfg.settings;
18 maintainers = teams.podman.members;
21 options.virtualisation.cri-o = {
22 enable = mkEnableOption "Container Runtime Interface for OCI (CRI-O)";
24 storageDriver = mkOption {
25 type = types.enum [ "aufs" "btrfs" "devmapper" "overlay" "vfs" "zfs" ];
27 description = "Storage driver to be used";
31 type = types.enum [ "trace" "debug" "info" "warn" "error" "fatal" ];
33 description = "Log level to be used";
36 pauseImage = mkOption {
37 type = types.nullOr types.str;
39 description = "Override the default pause image for pod sandboxes";
40 example = "k8s.gcr.io/pause:3.2";
43 pauseCommand = mkOption {
44 type = types.nullOr types.str;
46 description = "Override the default pause command";
51 type = types.nullOr types.str;
53 description = "Override the default runtime";
57 extraPackages = mkOption {
58 type = with types; listOf package;
60 example = literalExpression ''
66 Extra packages to be installed in the CRI-O wrapper.
72 default = crioPackage;
75 The final CRI-O package (including extra packages).
79 networkDir = mkOption {
80 type = types.nullOr types.path;
82 description = "Override the network_dir option.";
90 Configuration for cri-o, see
91 <https://github.com/cri-o/cri-o/blob/master/docs/crio.conf.5.md>.
96 config = mkIf cfg.enable {
97 environment.systemPackages = [ cfg.package pkgs.cri-tools ];
99 environment.etc."crictl.yaml".source = "${cfg.package}/etc/crictl.yaml";
101 virtualisation.cri-o.settings.crio = {
102 storage_driver = cfg.storageDriver;
105 pause_image = mkIf (cfg.pauseImage != null) cfg.pauseImage;
106 pause_command = mkIf (cfg.pauseCommand != null) cfg.pauseCommand;
110 plugin_dirs = [ "${pkgs.cni-plugins}/bin" ];
111 network_dir = mkIf (cfg.networkDir != null) cfg.networkDir;
115 cgroup_manager = "systemd";
116 log_level = cfg.logLevel;
117 manage_ns_lifecycle = true;
118 pinns_path = "${cfg.package}/bin/pinns";
120 optional (config.virtualisation.containers.ociSeccompBpfHook.enable)
121 config.boot.kernelPackages.oci-seccomp-bpf-hook;
123 default_runtime = mkIf (cfg.runtime != null) cfg.runtime;
124 runtimes = mkIf (cfg.runtime != null) {
125 "${cfg.runtime}" = { };
130 environment.etc."cni/net.d/10-crio-bridge.conflist".source = "${cfg.package}/etc/cni/net.d/10-crio-bridge.conflist";
131 environment.etc."cni/net.d/99-loopback.conflist".source = "${cfg.package}/etc/cni/net.d/99-loopback.conflist";
132 environment.etc."crio/crio.conf.d/00-default.conf".source = cfgFile;
134 # Enable common /etc/containers configuration
135 virtualisation.containers.enable = true;
137 systemd.services.crio = {
138 description = "Container Runtime Interface for OCI (CRI-O)";
139 documentation = [ "https://github.com/cri-o/cri-o" ];
140 wantedBy = [ "multi-user.target" ];
141 after = [ "network.target" ];
142 path = [ cfg.package ];
145 ExecStart = "${cfg.package}/bin/crio";
146 ExecReload = "/bin/kill -s HUP $MAINPID";
147 TasksMax = "infinity";
148 LimitNOFILE = "1048576";
149 LimitNPROC = "1048576";
150 LimitCORE = "infinity";
151 OOMScoreAdjust = "-999";
152 TimeoutStartSec = "0";
153 Restart = "on-abnormal";
155 restartTriggers = [ cfgFile ];