summary refs log tree commit diff
diff options
context:
space:
mode:
authorHaeNoe <programmierhaenoe@outlook.de>2023-10-05 20:39:19 +0200
committerHaeNoe <programmierhaenoe@outlook.de>2023-10-09 10:43:29 +0200
commit2f021def6e0a58e159e34b27b7796b2b5d0d0560 (patch)
tree0923f99c44f65a2fd61b47341144feeb63ef2826
parent99515b5c5071b358062a382d8b455633e7bfc76d (diff)
downloadnixpkgs-2f021def6e0a58e159e34b27b7796b2b5d0d0560.tar
nixpkgs-2f021def6e0a58e159e34b27b7796b2b5d0d0560.tar.gz
nixpkgs-2f021def6e0a58e159e34b27b7796b2b5d0d0560.tar.bz2
nixpkgs-2f021def6e0a58e159e34b27b7796b2b5d0d0560.tar.lz
nixpkgs-2f021def6e0a58e159e34b27b7796b2b5d0d0560.tar.xz
nixpkgs-2f021def6e0a58e159e34b27b7796b2b5d0d0560.tar.zst
nixpkgs-2f021def6e0a58e159e34b27b7796b2b5d0d0560.zip
nixos/oci-containers: add labels option
-rw-r--r--nixos/modules/virtualisation/oci-containers.nix12
1 files changed, 12 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/oci-containers.nix b/nixos/modules/virtualisation/oci-containers.nix
index a9f4ab77f86..71f5d7a752c 100644
--- a/nixos/modules/virtualisation/oci-containers.nix
+++ b/nixos/modules/virtualisation/oci-containers.nix
@@ -66,6 +66,17 @@ let
           '';
         };
 
+        labels = mkOption {
+          type = with types; attrsOf str;
+          default = {};
+          description = lib.mdDoc "Labels to attach to the container at runtime.";
+          example = literalExpression ''
+            {
+              "traefik.https.routers.example.rule" = "Host(`example.container`)";
+            }
+          '';
+        };
+
         entrypoint = mkOption {
           type = with types; nullOr str;
           description = lib.mdDoc "Override the default entrypoint of the image.";
@@ -277,6 +288,7 @@ let
       ++ map (p: "-p ${escapeShellArg p}") container.ports
       ++ optional (container.user != null) "-u ${escapeShellArg container.user}"
       ++ map (v: "-v ${escapeShellArg v}") container.volumes
+      ++ (mapAttrsToList (k: v: "-l ${escapeShellArg k}=${escapeShellArg v}") container.labels)
       ++ optional (container.workdir != null) "-w ${escapeShellArg container.workdir}"
       ++ map escapeShellArg container.extraOptions
       ++ [container.image]