From 3fdde458259a25526e9ab2a7bd4840e4a6f4400a Mon Sep 17 00:00:00 2001 From: pennae Date: Tue, 19 Jul 2022 14:36:08 +0200 Subject: [PATCH] nixos/oci-containers: convert option docs to MD no changes to the manpages, no rendering changes to the html manual --- .../modules/virtualisation/oci-containers.nix | 103 +++++++----------- 1 file changed, 40 insertions(+), 63 deletions(-) diff --git a/nixos/modules/virtualisation/oci-containers.nix b/nixos/modules/virtualisation/oci-containers.nix index fa5fe9973044..81cdf1dd72b4 100644 --- a/nixos/modules/virtualisation/oci-containers.nix +++ b/nixos/modules/virtualisation/oci-containers.nix @@ -14,18 +14,18 @@ let image = mkOption { type = with types; str; - description = "OCI image to run."; + description = lib.mdDoc "OCI image to run."; example = "library/hello-world"; }; imageFile = mkOption { type = with types; nullOr package; default = null; - description = '' + description = lib.mdDoc '' Path to an image file to load before running the image. This can be used to bypass pulling the image from the registry. - The image attribute must match the name and + The `image` attribute must match the name and tag of the image contained in this file, as they will be used to run the container with that image. If they do not match, the image will be pulled from the registry as usual. @@ -38,20 +38,20 @@ let username = mkOption { type = with types; nullOr str; default = null; - description = "Username for login."; + description = lib.mdDoc "Username for login."; }; passwordFile = mkOption { type = with types; nullOr str; default = null; - description = "Path to file containing password."; + description = lib.mdDoc "Path to file containing password."; example = "/etc/nixos/dockerhub-password.txt"; }; registry = mkOption { type = with types; nullOr str; default = null; - description = "Registry where to login to."; + description = lib.mdDoc "Registry where to login to."; example = "https://docker.pkg.github.com"; }; @@ -60,7 +60,7 @@ let cmd = mkOption { type = with types; listOf str; default = []; - description = "Commandline arguments to pass to the image's entrypoint."; + description = lib.mdDoc "Commandline arguments to pass to the image's entrypoint."; example = literalExpression '' ["--port=9000"] ''; @@ -68,7 +68,7 @@ let entrypoint = mkOption { type = with types; nullOr str; - description = "Override the default entrypoint of the image."; + description = lib.mdDoc "Override the default entrypoint of the image."; default = null; example = "/bin/my-app"; }; @@ -76,7 +76,7 @@ let environment = mkOption { type = with types; attrsOf str; default = {}; - description = "Environment variables to set for this container."; + description = lib.mdDoc "Environment variables to set for this container."; example = literalExpression '' { DATABASE_HOST = "db.example.com"; @@ -88,7 +88,7 @@ let environmentFiles = mkOption { type = with types; listOf path; default = []; - description = "Environment files for this container."; + description = lib.mdDoc "Environment files for this container."; example = literalExpression '' [ /path/to/.env @@ -100,15 +100,15 @@ let log-driver = mkOption { type = types.str; default = "journald"; - description = '' + description = lib.mdDoc '' Logging driver for the container. The default of - "journald" means that the container's logs will be + `"journald"` means that the container's logs will be handled as part of the systemd unit. For more details and a full list of logging drivers, refer to respective backends documentation. For Docker: - Docker engine documentation + [Docker engine documentation](https://docs.docker.com/engine/reference/run/#logging-drivers---log-driver) For Podman: Refer to the docker-run(1) man page. @@ -118,49 +118,27 @@ let ports = mkOption { type = with types; listOf str; default = []; - description = '' + description = lib.mdDoc '' Network ports to publish from the container to the outer host. Valid formats: + - `::` + - `::` + - `:` + - `` - - - - <ip>:<hostPort>:<containerPort> - - - - - <ip>::<containerPort> - - - - - <hostPort>:<containerPort> - - - - - <containerPort> - - - - - Both hostPort and - containerPort can be specified as a range of + Both `hostPort` and `containerPort` can be specified as a range of ports. When specifying ranges for both, the number of container ports in the range must match the number of host ports in the - range. Example: 1234-1236:1234-1236/tcp + range. Example: `1234-1236:1234-1236/tcp` - When specifying a range for hostPort only, the - containerPort must not be a - range. In this case, the container port is published somewhere - within the specified hostPort range. Example: - 1234-1236:1234/tcp + When specifying a range for `hostPort` only, the `containerPort` + must *not* be a range. In this case, the container port is published + somewhere within the specified `hostPort` range. + Example: `1234-1236:1234/tcp` Refer to the - - Docker engine documentation for full details. + [Docker engine documentation](https://docs.docker.com/engine/reference/run/#expose-incoming-ports) for full details. ''; example = literalExpression '' [ @@ -172,7 +150,7 @@ let user = mkOption { type = with types; nullOr str; default = null; - description = '' + description = lib.mdDoc '' Override the username or UID (and optionally groupname or GID) used in the container. ''; @@ -182,16 +160,15 @@ let volumes = mkOption { type = with types; listOf str; default = []; - description = '' + description = lib.mdDoc '' List of volumes to attach to this container. - Note that this is a list of "src:dst" strings to - allow for src to refer to - /nix/store paths, which would be difficult with an - attribute set. There are also a variety of mount options available - as a third field; please refer to the - - docker engine documentation for details. + Note that this is a list of `"src:dst"` strings to + allow for `src` to refer to `/nix/store` paths, which + would be difficult with an attribute set. There are + also a variety of mount options available as a third + field; please refer to the + [docker engine documentation](https://docs.docker.com/engine/reference/run/#volume-shared-filesystems) for details. ''; example = literalExpression '' [ @@ -204,17 +181,17 @@ let workdir = mkOption { type = with types; nullOr str; default = null; - description = "Override the default working directory for the container."; + description = lib.mdDoc "Override the default working directory for the container."; example = "/var/lib/hello_world"; }; dependsOn = mkOption { type = with types; listOf str; default = []; - description = '' + description = lib.mdDoc '' Define which other containers this one depends on. They will be added to both After and Requires for the unit. - Use the same name as the attribute under virtualisation.oci-containers.containers. + Use the same name as the attribute under `virtualisation.oci-containers.containers`. ''; example = literalExpression '' virtualisation.oci-containers.containers = { @@ -229,7 +206,7 @@ let extraOptions = mkOption { type = with types; listOf str; default = []; - description = "Extra options for ${defaultBackend} run."; + description = lib.mdDoc "Extra options for {command}`${defaultBackend} run`."; example = literalExpression '' ["--network=host"] ''; @@ -238,7 +215,7 @@ let autoStart = mkOption { type = types.bool; default = true; - description = '' + description = lib.mdDoc '' When enabled, the container is automatically started on boot. If this option is set to false, the container has to be started on-demand via its service. ''; @@ -339,13 +316,13 @@ in { backend = mkOption { type = types.enum [ "podman" "docker" ]; default = if versionAtLeast config.system.stateVersion "22.05" then "podman" else "docker"; - description = "The underlying Docker implementation to use."; + description = lib.mdDoc "The underlying Docker implementation to use."; }; containers = mkOption { default = {}; type = types.attrsOf (types.submodule containerOptions); - description = "OCI (Docker) containers to run as systemd services."; + description = lib.mdDoc "OCI (Docker) containers to run as systemd services."; }; };