nixos/containerd: improve zfs support
This commit is contained in:
parent
4542b54abd
commit
f2e4cb7f20
|
@ -1,10 +1,20 @@
|
||||||
{ pkgs, lib, config, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.virtualisation.containerd;
|
cfg = config.virtualisation.containerd;
|
||||||
containerdConfigChecked = pkgs.runCommand "containerd-config-checked.toml" { nativeBuildInputs = [pkgs.containerd]; } ''
|
|
||||||
containerd -c ${cfg.configFile} config dump >/dev/null
|
configFile = if cfg.configFile == null then
|
||||||
ln -s ${cfg.configFile} $out
|
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
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -13,10 +23,21 @@ in
|
||||||
|
|
||||||
configFile = lib.mkOption {
|
configFile = lib.mkOption {
|
||||||
default = null;
|
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;
|
type = nullOr path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
settings = lib.mkOption {
|
||||||
|
type = settingsFormat.type;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Verbatim lines to add to containerd.toml
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
args = lib.mkOption {
|
args = lib.mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
description = "extra args to append to the containerd cmdline";
|
description = "extra args to append to the containerd cmdline";
|
||||||
|
@ -25,9 +46,19 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
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.
|
||||||
|
'';
|
||||||
|
|
||||||
environment.systemPackages = [pkgs.containerd];
|
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 ];
|
||||||
|
|
||||||
systemd.services.containerd = {
|
systemd.services.containerd = {
|
||||||
description = "containerd - container runtime";
|
description = "containerd - container runtime";
|
||||||
|
@ -37,7 +68,7 @@ in
|
||||||
containerd
|
containerd
|
||||||
runc
|
runc
|
||||||
iptables
|
iptables
|
||||||
];
|
] ++ lib.optional config.boot.zfs.enabled config.boot.zfs.package;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = ''${pkgs.containerd}/bin/containerd ${lib.concatStringsSep " " (lib.cli.toGNUCommandLine {} cfg.args)}'';
|
ExecStart = ''${pkgs.containerd}/bin/containerd ${lib.concatStringsSep " " (lib.cli.toGNUCommandLine {} cfg.args)}'';
|
||||||
Delegate = "yes";
|
Delegate = "yes";
|
||||||
|
|
Loading…
Reference in a new issue