8 cfg = config.virtualisation.containerd;
11 if cfg.configFile == null then
12 settingsFormat.generate "containerd.toml" cfg.settings
16 containerdConfigChecked =
17 pkgs.runCommand "containerd-config-checked.toml"
19 nativeBuildInputs = [ pkgs.containerd ];
22 containerd -c ${configFile} config dump >/dev/null
23 ln -s ${configFile} $out
26 settingsFormat = pkgs.formats.toml { };
30 options.virtualisation.containerd = with lib.types; {
31 enable = lib.mkEnableOption "containerd container runtime";
33 configFile = lib.mkOption {
36 Path to containerd config file.
37 Setting this option will override any configuration applied by the settings option.
42 settings = lib.mkOption {
43 type = settingsFormat.type;
46 Verbatim lines to add to containerd.toml
52 description = "extra args to append to the containerd cmdline";
57 config = lib.mkIf cfg.enable {
58 warnings = lib.optional (cfg.configFile != null) ''
59 `virtualisation.containerd.configFile` is deprecated. use `virtualisation.containerd.settings` instead.
62 virtualisation.containerd = {
63 args.config = toString containerdConfigChecked;
66 plugins."io.containerd.grpc.v1.cri" = {
67 containerd.snapshotter = lib.mkIf config.boot.zfs.enabled (lib.mkOptionDefault "zfs");
68 cni.bin_dir = lib.mkOptionDefault "${pkgs.cni-plugins}/bin";
73 environment.systemPackages = [ pkgs.containerd ];
75 systemd.services.containerd = {
76 description = "containerd - container runtime";
77 wantedBy = [ "multi-user.target" ];
90 ++ lib.optional config.boot.zfs.enabled config.boot.zfs.package;
92 ExecStart = ''${pkgs.containerd}/bin/containerd ${
93 lib.concatStringsSep " " (lib.cli.toGNUCommandLine { } cfg.args)
101 # "limits" defined below are adopted from upstream: https://github.com/containerd/containerd/blob/master/containerd.service
102 LimitNPROC = "infinity";
103 LimitCORE = "infinity";
104 TasksMax = "infinity";
105 OOMScoreAdjust = "-999";
107 StateDirectory = "containerd";
108 RuntimeDirectory = "containerd";
109 RuntimeDirectoryPreserve = "yes";
112 StartLimitBurst = "16";
113 StartLimitIntervalSec = "120s";