mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
117 lines
3 KiB
Nix
117 lines
3 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.virtualisation.containerd;
|
|
|
|
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
|
|
{
|
|
|
|
options.virtualisation.containerd = with lib.types; {
|
|
enable = lib.mkEnableOption "containerd container runtime";
|
|
|
|
configFile = lib.mkOption {
|
|
default = null;
|
|
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";
|
|
type = attrsOf str;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
warnings = lib.optional (cfg.configFile != null) ''
|
|
`virtualisation.containerd.configFile` is deprecated. use `virtualisation.containerd.settings` instead.
|
|
'';
|
|
|
|
virtualisation.containerd = {
|
|
args.config = toString containerdConfigChecked;
|
|
settings = {
|
|
version = 2;
|
|
plugins."io.containerd.grpc.v1.cri" = {
|
|
containerd.snapshotter = lib.mkIf config.boot.zfs.enabled (lib.mkOptionDefault "zfs");
|
|
cni.bin_dir = lib.mkOptionDefault "${pkgs.cni-plugins}/bin";
|
|
};
|
|
};
|
|
};
|
|
|
|
environment.systemPackages = [ pkgs.containerd ];
|
|
|
|
systemd.services.containerd = {
|
|
description = "containerd - container runtime";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [
|
|
"network.target"
|
|
"local-fs.target"
|
|
"dbus.service"
|
|
];
|
|
path =
|
|
with pkgs;
|
|
[
|
|
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";
|
|
KillMode = "process";
|
|
Type = "notify";
|
|
Restart = "always";
|
|
RestartSec = "10";
|
|
|
|
# "limits" defined below are adopted from upstream: https://github.com/containerd/containerd/blob/master/containerd.service
|
|
LimitNPROC = "infinity";
|
|
LimitCORE = "infinity";
|
|
TasksMax = "infinity";
|
|
OOMScoreAdjust = "-999";
|
|
|
|
StateDirectory = "containerd";
|
|
RuntimeDirectory = "containerd";
|
|
RuntimeDirectoryPreserve = "yes";
|
|
};
|
|
unitConfig = {
|
|
StartLimitBurst = "16";
|
|
StartLimitIntervalSec = "120s";
|
|
};
|
|
};
|
|
};
|
|
}
|