1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

Merge pull request #1 from bamhm182/suggestions-dawidd6-podman

podman: moved settings under config
This commit is contained in:
Dawid Dziurla 2024-11-08 17:04:06 +01:00 committed by GitHub
commit c6e927e632
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 84 additions and 79 deletions

View file

@ -11,61 +11,63 @@ in {
options.services.podman = { options.services.podman = {
enable = lib.mkEnableOption "Podman, a daemonless container engine"; enable = lib.mkEnableOption "Podman, a daemonless container engine";
containersConf.settings = lib.mkOption { config = {
type = toml.type; containers.settings = lib.mkOption {
default = { }; type = toml.type;
description = "containers.conf configuration"; default = { };
}; description = "containers.conf configuration";
storage.settings = 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 { storage.settings = lib.mkOption {
default = [ ]; type = toml.type;
type = lib.types.listOf lib.types.str; description = "storage.conf configuration";
description = ''
List of insecure repositories.
'';
}; };
block = lib.mkOption { registries = {
default = [ ]; search = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
description = '' default = [ "docker.io" ];
List of blocked repositories. description = ''
''; List of repositories to search.
}; '';
}; };
policy = lib.mkOption { insecure = lib.mkOption {
default = { }; default = [ ];
type = lib.types.attrs; type = lib.types.listOf lib.types.str;
example = lib.literalExpression '' description = ''
{ List of insecure repositories.
default = [ { type = "insecureAcceptAnything"; } ]; '';
transports = { };
docker-daemon = {
"" = [ { type = "insecureAcceptAnything"; } ]; 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 = ''
description = '' Signature verification policy file.
Signature verification policy file. If this option is empty the default policy file from
If this option is empty the default policy file from `skopeo` will be used.
`skopeo` will be used. '';
''; };
}; };
}; };
@ -75,22 +77,23 @@ in {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
services.podman.storage.settings = { services.podman.config.storage.settings = {
storage.driver = lib.mkDefault "overlay"; storage.driver = lib.mkDefault "overlay";
}; };
xdg.configFile = { xdg.configFile = {
"containers/policy.json".source = if cfg.policy != { } then "containers/policy.json".source = if cfg.config.policy != { } then
pkgs.writeText "policy.json" (builtins.toJSON cfg.policy) pkgs.writeText "policy.json" (builtins.toJSON cfg.config.policy)
else else
"${pkgs.skopeo.policy}/default-policy.json"; "${pkgs.skopeo.policy}/default-policy.json";
"containers/registries.conf".source = toml.generate "registries.conf" { "containers/registries.conf".source = toml.generate "registries.conf" {
registries = lib.mapAttrs (n: v: { registries = v; }) cfg.registries; registries =
lib.mapAttrs (n: v: { registries = v; }) cfg.config.registries;
}; };
"containers/storage.conf".source = "containers/storage.conf".source =
toml.generate "storage.conf" cfg.storage.settings; toml.generate "storage.conf" cfg.config.storage.settings;
"containers/containers.conf".source = "containers/containers.conf".source =
toml.generate "containers.conf" cfg.containersConf.settings; toml.generate "containers.conf" cfg.config.containers.settings;
}; };
}; };
} }

View file

@ -3,33 +3,35 @@
{ {
services.podman = { services.podman = {
enable = true; enable = true;
containersConf.settings = { config = {
network = { containers.settings = {
default_subnet = "172.16.10.0/24"; network = {
default_subnet_pools = [ default_subnet = "172.16.10.0/24";
{ default_subnet_pools = [
base = "172.16.11.0/24"; {
size = 24; base = "172.16.11.0/24";
} size = 24;
{ }
base = "172.16.12.0/24"; {
size = 24; base = "172.16.12.0/24";
} size = 24;
]; }
];
};
}; };
}; storage.settings = {
storage.settings = { storage = {
storage = { runroot = "$HOME/.containers/runroot";
runroot = "$HOME/.containers/runroot"; graphroot = "$HOME/.containers/graphroot";
graphroot = "$HOME/.containers/graphroot"; };
}; };
registries = {
block = [ "ghcr.io" "gallery.ecr.aws" ];
insecure = [ "quay.io" ];
search = [ "docker.io" ];
};
policy = { default = [{ type = "insecureAcceptAnything"; }]; };
}; };
registries = {
block = [ "ghcr.io" "gallery.ecr.aws" ];
insecure = [ "quay.io" ];
search = [ "docker.io" ];
};
policy = { default = [{ type = "insecureAcceptAnything"; }]; };
}; };
nmt.script = '' nmt.script = ''