diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2021-06-01 20:43:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 20:43:11 +0200 |
commit | 79ef19e02b32055d36452473390701b921bb2021 (patch) | |
tree | 74379664080de1f2d1402c877558df61137a28e0 | |
parent | e7af2715871a42dfcce0a62718c57ab677712c5d (diff) | |
parent | f2e4cb7f20bc3919fec844741120d85aad2cab98 (diff) | |
download | nixpkgs-79ef19e02b32055d36452473390701b921bb2021.tar nixpkgs-79ef19e02b32055d36452473390701b921bb2021.tar.gz nixpkgs-79ef19e02b32055d36452473390701b921bb2021.tar.bz2 nixpkgs-79ef19e02b32055d36452473390701b921bb2021.tar.lz nixpkgs-79ef19e02b32055d36452473390701b921bb2021.tar.xz nixpkgs-79ef19e02b32055d36452473390701b921bb2021.tar.zst nixpkgs-79ef19e02b32055d36452473390701b921bb2021.zip |
Merge pull request #125169 from Mic92/containerd-zfs
nixos/containerd: improve zfs support
-rw-r--r-- | nixos/modules/virtualisation/containerd.nix | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/nixos/modules/virtualisation/containerd.nix b/nixos/modules/virtualisation/containerd.nix index b554bc6ea24..c7ceb816a31 100644 --- a/nixos/modules/virtualisation/containerd.nix +++ b/nixos/modules/virtualisation/containerd.nix @@ -1,10 +1,20 @@ { pkgs, lib, config, ... }: let cfg = config.virtualisation.containerd; - containerdConfigChecked = pkgs.runCommand "containerd-config-checked.toml" { nativeBuildInputs = [pkgs.containerd]; } '' - containerd -c ${cfg.configFile} config dump >/dev/null - ln -s ${cfg.configFile} $out + + configFile = if cfg.configFile == null then + settingsFormat.generate "containerd.toml" cfg.settings + else + cfg.configFile; + + containerdConfigChecked = pkgs.runCommand "containerd-config-checked.toml" { + nativeBuildInputs = [ pkgs.containerd ]; + } '' + containerd -c ${configFile} config dump >/dev/null + ln -s ${configFile} $out ''; + + settingsFormat = pkgs.formats.toml {}; in { @@ -13,10 +23,21 @@ in configFile = lib.mkOption { default = null; - description = "path to containerd config file"; + description = '' + Path to containerd config file. + Setting this option will override any configuration applied by the settings option. + ''; type = nullOr path; }; + settings = lib.mkOption { + type = settingsFormat.type; + default = {}; + description = '' + Verbatim lines to add to containerd.toml + ''; + }; + args = lib.mkOption { default = {}; description = "extra args to append to the containerd cmdline"; @@ -25,9 +46,19 @@ in }; config = lib.mkIf cfg.enable { - virtualisation.containerd.args.config = lib.mkIf (cfg.configFile != null) (toString containerdConfigChecked); + warnings = lib.optional (cfg.configFile != null) '' + `virtualisation.containerd.configFile` is deprecated. use `virtualisation.containerd.settings` instead. + ''; + + virtualisation.containerd = { + args.config = toString containerdConfigChecked; + settings = { + plugins.cri.containerd.snapshotter = lib.mkIf config.boot.zfs.enabled "zfs"; + plugins.cri.cni.bin_dir = lib.mkDefault "${pkgs.cni-plugins}/bin"; + }; + }; - environment.systemPackages = [pkgs.containerd]; + environment.systemPackages = [ pkgs.containerd ]; systemd.services.containerd = { description = "containerd - container runtime"; @@ -37,7 +68,7 @@ in containerd runc iptables - ]; + ] ++ lib.optional config.boot.zfs.enabled config.boot.zfs.package; serviceConfig = { ExecStart = ''${pkgs.containerd}/bin/containerd ${lib.concatStringsSep " " (lib.cli.toGNUCommandLine {} cfg.args)}''; Delegate = "yes"; |