2023-12-22 01:24:18 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2024-11-23 22:36:33 +01:00
|
|
|
let
|
|
|
|
cfg = config.services.podman;
|
|
|
|
toml = pkgs.formats.toml { };
|
|
|
|
in {
|
2023-12-22 01:24:18 +01:00
|
|
|
meta.maintainers = with lib.hm.maintainers; [ bamhm182 n-hass ];
|
|
|
|
|
|
|
|
imports =
|
|
|
|
[ ./containers.nix ./install-quadlet.nix ./networks.nix ./services.nix ];
|
|
|
|
|
|
|
|
options.services.podman = {
|
|
|
|
enable = lib.mkEnableOption "Podman, a daemonless container engine";
|
2024-11-23 22:36:33 +01:00
|
|
|
|
|
|
|
settings = {
|
|
|
|
containers = lib.mkOption {
|
|
|
|
type = toml.type;
|
|
|
|
default = { };
|
|
|
|
description = "containers.conf configuration";
|
|
|
|
};
|
|
|
|
|
|
|
|
storage = lib.mkOption {
|
|
|
|
type = toml.type;
|
|
|
|
description = "storage.conf configuration";
|
|
|
|
};
|
|
|
|
|
|
|
|
registries = {
|
|
|
|
search = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
default = [ "docker.io" ];
|
|
|
|
description = ''
|
|
|
|
List of repositories to search.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
insecure = lib.mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
description = ''
|
|
|
|
List of insecure repositories.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
block = lib.mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
description = ''
|
|
|
|
List of blocked repositories.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
policy = lib.mkOption {
|
|
|
|
default = { };
|
|
|
|
type = lib.types.attrs;
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
{
|
|
|
|
default = [ { type = "insecureAcceptAnything"; } ];
|
|
|
|
transports = {
|
|
|
|
docker-daemon = {
|
|
|
|
"" = [ { type = "insecureAcceptAnything"; } ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Signature verification policy file.
|
|
|
|
If this option is empty the default policy file from
|
|
|
|
`skopeo` will be used.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2023-12-22 01:24:18 +01:00
|
|
|
};
|
|
|
|
|
2024-11-23 22:36:33 +01:00
|
|
|
config = lib.mkIf cfg.enable {
|
2023-12-22 01:24:18 +01:00
|
|
|
assertions =
|
|
|
|
[ (lib.hm.assertions.assertPlatform "podman" pkgs lib.platforms.linux) ];
|
2024-11-23 22:36:33 +01:00
|
|
|
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
services.podman.settings.storage = {
|
|
|
|
storage.driver = lib.mkDefault "overlay";
|
|
|
|
};
|
|
|
|
|
|
|
|
xdg.configFile = {
|
|
|
|
"containers/policy.json".source = if cfg.settings.policy != { } then
|
|
|
|
pkgs.writeText "policy.json" (builtins.toJSON cfg.settings.policy)
|
|
|
|
else
|
|
|
|
"${pkgs.skopeo.policy}/default-policy.json";
|
|
|
|
"containers/registries.conf".source = toml.generate "registries.conf" {
|
|
|
|
registries =
|
|
|
|
lib.mapAttrs (n: v: { registries = v; }) cfg.settings.registries;
|
|
|
|
};
|
|
|
|
"containers/storage.conf".source =
|
|
|
|
toml.generate "storage.conf" cfg.settings.storage;
|
|
|
|
"containers/containers.conf".source =
|
|
|
|
toml.generate "containers.conf" cfg.settings.containers;
|
|
|
|
};
|
2023-12-22 01:24:18 +01:00
|
|
|
};
|
|
|
|
}
|