From b2b3f5d68db96969510e313ef33fa3367bbcc14b Mon Sep 17 00:00:00 2001 From: tomf Date: Thu, 6 Jun 2024 08:18:37 +1000 Subject: [PATCH] nixos/oci-containers: add preRunExtraOptions (#315356) `podman --help` and `docker --help` each have global options, that must be specified before `run`. --- nixos/modules/virtualisation/oci-containers.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/oci-containers.nix b/nixos/modules/virtualisation/oci-containers.nix index 4308d410c69c..f4fa93423179 100644 --- a/nixos/modules/virtualisation/oci-containers.nix +++ b/nixos/modules/virtualisation/oci-containers.nix @@ -221,6 +221,13 @@ let example = "hello-world"; }; + preRunExtraOptions = mkOption { + type = with types; listOf str; + default = []; + description = "Extra options for {command}`${defaultBackend}` that go before the `run` argument."; + example = [ "--runtime" "runsc" ]; + }; + extraOptions = mkOption { type = with types; listOf str; default = []; @@ -284,7 +291,9 @@ let else throw "Unhandled backend: ${cfg.backend}"; script = concatStringsSep " \\\n " ([ - "exec ${cfg.backend} run" + "exec ${cfg.backend} " + ] ++ map escapeShellArg container.preRunExtraOptions ++ [ + "run" "--rm" "--name=${escapedName}" "--log-driver=${container.log-driver}"