about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorSarah Brofeldt <sbrofeldt@gmail.com>2023-10-09 18:52:20 +0200
committerGitHub <noreply@github.com>2023-10-09 18:52:20 +0200
commita655e7a1aa2eeb9416ddc888c7815312e9b9d7c7 (patch)
treebe335088fff50ccaeacedae36b56e85b7b0e1409 /nixos/modules
parent7de5f5de5dd28de59e04c3de4f5b472fd4735240 (diff)
parent2f021def6e0a58e159e34b27b7796b2b5d0d0560 (diff)
downloadnixlib-a655e7a1aa2eeb9416ddc888c7815312e9b9d7c7.tar
nixlib-a655e7a1aa2eeb9416ddc888c7815312e9b9d7c7.tar.gz
nixlib-a655e7a1aa2eeb9416ddc888c7815312e9b9d7c7.tar.bz2
nixlib-a655e7a1aa2eeb9416ddc888c7815312e9b9d7c7.tar.lz
nixlib-a655e7a1aa2eeb9416ddc888c7815312e9b9d7c7.tar.xz
nixlib-a655e7a1aa2eeb9416ddc888c7815312e9b9d7c7.tar.zst
nixlib-a655e7a1aa2eeb9416ddc888c7815312e9b9d7c7.zip
Merge pull request #259240 from haenoe/oci-containers-labels-option
nixos/oci-containers: add labels option
Diffstat (limited to 'nixos/modules')
-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 a9f4ab77f866..71f5d7a752c8 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]