2021-09-12 23:46:22 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.podman;
|
|
|
|
toml = pkgs.formats.toml { };
|
|
|
|
json = pkgs.formats.json { };
|
|
|
|
|
|
|
|
inherit (lib) mkOption types;
|
|
|
|
|
|
|
|
podmanPackage = (pkgs.podman.override { inherit (cfg) extraPackages; });
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
#./podman-network-socket.nix
|
|
|
|
(lib.mkRenamedOptionModule [ "virtualisation" "podman" "libpod" ] [ "virtualisation" "containers" "containersConf" ])
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
maintainers = lib.teams.podman.members;
|
|
|
|
};
|
|
|
|
|
|
|
|
options.services.podman = {
|
|
|
|
|
|
|
|
enable =
|
|
|
|
mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
This option enables Podman, a daemonless container engine for
|
|
|
|
developing, managing, and running OCI Containers on your Linux System.
|
|
|
|
|
|
|
|
It is a drop-in replacement for the <command>docker</command> command.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableNvidia = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enable use of NVidia GPUs from within podman containers.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [ ];
|
|
|
|
example = lib.literalExample ''
|
|
|
|
[
|
|
|
|
pkgs.gvisor
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages to be installed in the Podman wrapper.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = podmanPackage;
|
|
|
|
internal = true;
|
|
|
|
description = ''
|
|
|
|
The final Podman package (including extra packages).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultNetwork.extraPlugins = lib.mkOption {
|
|
|
|
type = types.listOf json.type;
|
|
|
|
default = [ ];
|
|
|
|
description = ''
|
|
|
|
Extra CNI plugin configurations to add to podman's default network.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-09-08 14:45:12 +02:00
|
|
|
config = lib.mkIf cfg.enable
|
2021-09-12 23:46:22 +02:00
|
|
|
{
|
2022-09-08 14:45:12 +02:00
|
|
|
home.packages = [ cfg.package ];
|
2023-01-14 20:36:28 +01:00
|
|
|
xdg.configFile."containers/networks/podman.json".source = json.generate "podman.json" ({
|
|
|
|
dns_enabled = false;
|
|
|
|
driver = "bridge";
|
|
|
|
id = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
|
|
internal = false;
|
|
|
|
ipam_options = { driver = "host-local"; };
|
|
|
|
ipv6_enabled = false;
|
|
|
|
name = "podman";
|
|
|
|
network_interface = "podman0";
|
|
|
|
subnets = [{ gateway = "10.88.0.1"; subnet = "10.88.0.0/16"; }];
|
|
|
|
});
|
2021-09-12 23:46:22 +02:00
|
|
|
virtualisation.containers = {
|
|
|
|
enable = true; # Enable common /etc/containers configuration
|
|
|
|
containersConf.settings = lib.optionalAttrs cfg.enableNvidia {
|
2023-01-14 20:36:28 +01:00
|
|
|
network.network_backend = "netavark";
|
2021-09-12 23:46:22 +02:00
|
|
|
engine = {
|
|
|
|
conmon_env_vars = [ "PATH=${lib.makeBinPath [ pkgs.nvidia-podman ]}" ];
|
|
|
|
runtimes.nvidia = [ "${pkgs.nvidia-podman}/bin/nvidia-container-runtime" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user = {
|
|
|
|
|
|
|
|
services.podman = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Podman API Service";
|
|
|
|
Requires = "podman.socket";
|
|
|
|
After = "podman.socket";
|
|
|
|
Documentation = "man:podman-system-service(1)";
|
|
|
|
StartLimitIntervalSec = 0;
|
|
|
|
};
|
|
|
|
Service = {
|
|
|
|
Type = "exec";
|
|
|
|
KillMode = "process";
|
2022-11-17 20:58:01 +01:00
|
|
|
Environment = [ "LOGGING=\" --log-level=info\"" ];
|
|
|
|
ExecStart = "${pkgs.bash}/bin/bash -c 'PATH=\"$PATH:/run/wrappers/bin\" ${cfg.package}/bin/podman $LOGGING system service'";
|
2021-09-12 23:46:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Install = {
|
|
|
|
WantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
sockets.podman = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Podman API Socket";
|
|
|
|
Documentation = "man:podman-system-service(1)";
|
|
|
|
};
|
|
|
|
Socket = {
|
|
|
|
ListenStream = "%t/podman/podman.sock";
|
|
|
|
SocketMode = 0660;
|
|
|
|
};
|
|
|
|
Install.WantedBy = [ "sockets.target" ];
|
|
|
|
};
|
|
|
|
};
|
2022-09-08 14:45:12 +02:00
|
|
|
};
|
2022-06-29 00:02:00 +02:00
|
|
|
}
|