mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-01 06:31:04 +01:00
podman: added volume, image, and build quadlets (#6137)
Added support for build, image, and volume quadlets Resolved test failures due to podman 5.3.0 upgrade Replaced several instances of pkgs.podman with services.podman.package
This commit is contained in:
parent
f8bb0ba6de
commit
ce9cb2496c
24 changed files with 1000 additions and 54 deletions
|
|
@ -1,4 +1,4 @@
|
|||
{ lib, config, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
|
|
@ -63,8 +63,10 @@ in {
|
|||
buildConfigAsserts = quadletName: extraConfig:
|
||||
let
|
||||
configRules = {
|
||||
Build = { ImageTag = (with types; listOf str); };
|
||||
Container = { ContainerName = types.enum [ quadletName ]; };
|
||||
Network = { NetworkName = types.enum [ quadletName ]; };
|
||||
Volume = { VolumeName = types.enum [ quadletName ]; };
|
||||
};
|
||||
|
||||
# Function to build assertions for a specific section and its attributes.
|
||||
|
|
@ -83,8 +85,23 @@ in {
|
|||
else
|
||||
[ ];
|
||||
|
||||
checkImageTag = extraConfig:
|
||||
let
|
||||
imageTags = (extraConfig.Build or { }).ImageTag or [ ];
|
||||
containsRequiredTag =
|
||||
builtins.elem "homemanager/${quadletName}" imageTags;
|
||||
imageTagsStr = concatMapStringsSep ''" "'' toString imageTags;
|
||||
in [{
|
||||
assertion = imageTags == [ ] || containsRequiredTag;
|
||||
message = ''
|
||||
In '${quadletName}' config. Build.ImageTag: '[ "${imageTagsStr}" ]' does not contain 'homemanager/${quadletName}'.'';
|
||||
}];
|
||||
|
||||
# Flatten assertions from all sections in `extraConfig`.
|
||||
in flatten (mapAttrsToList buildSectionAsserts extraConfig);
|
||||
in flatten (concatLists [
|
||||
(mapAttrsToList buildSectionAsserts extraConfig)
|
||||
(checkImageTag extraConfig)
|
||||
]);
|
||||
|
||||
extraConfigType = with types;
|
||||
attrsOf (attrsOf (oneOf [ primitiveAttrs primitiveList primitive ]));
|
||||
|
|
@ -107,8 +124,10 @@ in {
|
|||
# specific logic for writing the unit name goes here. It should be
|
||||
# identical to what `podman <resource> ls` shows
|
||||
in {
|
||||
"build" = "localhost/homemanager/${strippedName}";
|
||||
"container" = strippedName;
|
||||
"network" = strippedName;
|
||||
"volume" = strippedName;
|
||||
}."${quadlet.resourceType}";
|
||||
in if allQuadletsSameType then ''
|
||||
${concatStringsSep "\n"
|
||||
|
|
@ -133,4 +152,10 @@ in {
|
|||
lines = splitString "\n" text;
|
||||
nonEmptyLines = filter (line: line != "") lines;
|
||||
in concatStringsSep "\n" nonEmptyLines;
|
||||
|
||||
awaitPodmanUnshare = pkgs.writeShellScript "await-podman-unshare" ''
|
||||
until ${config.services.podman.package}/bin/podman unshare ${pkgs.coreutils}/bin/true; do
|
||||
${pkgs.coreutils}/bin/sleep 1
|
||||
done
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue