From bc24209c5b0b699adad56b8cdd2fe4a9420886dd Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 4 Feb 2024 22:18:14 +0100 Subject: [PATCH] runner: make prettyProcnames configurable --- lib/runner.nix | 5 ++++- nixos-modules/microvm/options.nix | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/runner.nix b/lib/runner.nix index 4654f9fc..5ebc0b99 100644 --- a/lib/runner.nix +++ b/lib/runner.nix @@ -19,6 +19,9 @@ let preStart = hypervisorConfig.preStart or microvmConfig.preStart; tapMultiQueue = hypervisorConfig.tapMultiQueue or false; + execArg = lib.optionalString microvmConfig.prettyProcname + ''-a "microvm@${microvmConfig.hostName}"''; + runScriptBin = pkgs.buildPackages.writeScriptBin "microvm-run" '' #! ${pkgs.buildPackages.runtimeShell} -e @@ -26,7 +29,7 @@ let ${createVolumesScript pkgs.buildPackages microvmConfig.volumes} ${lib.optionalString (hypervisorConfig.requiresMacvtapAsFds or false) openMacvtapFds} - exec -a "microvm-${microvmConfig.hostName}" ${command} + exec ${execArg} ${command} ''; shutdownScriptBin = pkgs.buildPackages.writeScriptBin "microvm-shutdown" '' diff --git a/nixos-modules/microvm/options.nix b/nixos-modules/microvm/options.nix index 1f36e5cf..2d22e452 100644 --- a/nixos-modules/microvm/options.nix +++ b/nixos-modules/microvm/options.nix @@ -414,6 +414,14 @@ in description = "A Hypervisor's sandbox directory"; }; + prettyProcnames = mkOption { + type = types.bool; + default = true; + description = '' + Set a recognizable process name right before executing the Hyperisor. + ''; + }; + runner = mkOption { description = "Generated Hypervisor runner for this NixOS"; type = with types; attrsOf package;