Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
nixos/podman: support configuring registries and policy
- Loading branch information
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ config, pkgs, lib, ... }: | ||
|
||
let | ||
cfg = config.programs.podman; | ||
|
||
surroundEachWith = str: list: | ||
map (e: str + (toString e) + str) list; | ||
|
||
registriesConf = let | ||
registryList = list: | ||
"registries = [" + (lib.concatStringsSep ", " (surroundEachWith "'" list)) + "]"; | ||
in lib.concatStringsSep "\n" (lib.mapAttrsToList (type: registries: '' | ||
[registries.${type}] | ||
${registryList registries} | ||
'') { inherit (cfg.registries) block insecure search; }); | ||
|
||
in { | ||
###### interface | ||
|
||
options = { | ||
programs.podman = with lib; { | ||
|
||
enable = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = "Whenever to configure <command>podman</command> system-wide."; | ||
}; | ||
|
||
installSystemWide = mkOption { | ||
type = types.bool; | ||
default = true; | ||
description = "Install packages system-wide."; | ||
}; | ||
|
||
registries = { | ||
search = mkOption { | ||
type = types.listOf types.str; | ||
default = [ "docker.io" "quay.io" ]; | ||
description = '' | ||
List of repositories to search. | ||
''; | ||
}; | ||
|
||
insecure = mkOption { | ||
default = [ ]; | ||
type = types.listOf types.str; | ||
description = '' | ||
List of insecure repositories. | ||
''; | ||
}; | ||
|
||
block = mkOption { | ||
default = [ ]; | ||
type = types.listOf types.str; | ||
description = '' | ||
List of blocked repositories. | ||
''; | ||
}; | ||
}; | ||
|
||
policy = mkOption { | ||
default = { | ||
default = [ { type = "reject"; }]; | ||
}; | ||
type = types.attrs; | ||
literalExample = '' | ||
{ | ||
default = [ { type = "insecureAcceptAnything"; } ]; | ||
transports = { | ||
docker-daemon = { | ||
"" = [ { type = "insecureAcceptAnything"; } ]; | ||
}; | ||
}; | ||
} | ||
''; | ||
description = '' | ||
Signature verification policy file | ||
</para> | ||
<para> | ||
The default will simply reject everything. | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
###### implementation | ||
|
||
config = lib.mkIf cfg.enable { | ||
environment = { | ||
etc."containers/registries.conf".text = registriesConf; | ||
etc."containers/policy.json".text = builtins.toJSON cfg.policy; | ||
|
||
systemPackages = lib.mkIf cfg.installSystemWide | ||
(with pkgs; [ buildah fuse-overlayfs podman runc slirp4netns ]); | ||
}; | ||
}; | ||
} |