From d01038921c03a0237a1a23cb4b7ad94ca94036a5 Mon Sep 17 00:00:00 2001 From: lucasew Date: Wed, 1 Jan 2025 22:36:24 -0300 Subject: [PATCH] nixos/oci-containers: option to set the service name of a oci-container Signed-off-by: lucasew --- nixos/modules/virtualisation/oci-containers.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nixos/modules/virtualisation/oci-containers.nix b/nixos/modules/virtualisation/oci-containers.nix index 61593dc234ab7..89e2b7e0f8632 100644 --- a/nixos/modules/virtualisation/oci-containers.nix +++ b/nixos/modules/virtualisation/oci-containers.nix @@ -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 = "-"; + 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