nixos/oci-containers: option to set the service name of a oci-ontainer (#370089)

This commit is contained in:
Gaétan Lepage
2025-01-04 15:39:41 +01:00
committed by GitHub

View File

@@ -14,7 +14,7 @@ let
defaultBackend = options.virtualisation.oci-containers.backend.default;
containerOptions =
{ ... }:
{ name, ... }:
{
options = {
@@ -59,6 +59,13 @@ let
example = literalExpression "pkgs.dockerTools.streamLayeredImage {...};";
};
serviceName = mkOption {
type = types.str;
default = "${cfg.backend}-${name}";
defaultText = "<backend>-<name>";
description = "Systemd service name that manages the container";
};
login = {
username = mkOption {
@@ -525,9 +532,7 @@ in
config = lib.mkIf (cfg.containers != { }) (
lib.mkMerge [
{
systemd.services = mapAttrs' (
n: v: nameValuePair "${cfg.backend}-${n}" (mkService n v)
) cfg.containers;
systemd.services = mapAttrs' (n: v: nameValuePair v.serviceName (mkService n v)) cfg.containers;
assertions =
let