diff --git a/lib/runners/firecracker.nix b/lib/runners/firecracker.nix index a73f97fb..356898cd 100644 --- a/lib/runners/firecracker.nix +++ b/lib/runners/firecracker.nix @@ -20,7 +20,7 @@ let }.${system}; # Firecracker config, as JSON in `configFile` - config = { + baseConfig = { boot-source = { kernel_image_path = kernelPath; initrd_path = initrdPath; @@ -65,6 +65,7 @@ let } // lib.optionalAttrs (cpu != null) { cpu-config = pkgs.writeText "cpu-config.json" (builtins.toJSON cpu); }; + config = lib.recursiveUpdate baseConfig microvmConfig.firecracker.extraConfig; configFile = pkgs.writers.writeJSON "firecracker-${hostName}.json" config; @@ -86,7 +87,7 @@ in { then throw "hotpluggedMem not implemented for Firecracker" else if credentialFiles != {} then throw "credentialFiles are not implemented for Firecracker" - else lib.escapeShellArgs [ + else lib.escapeShellArgs ([ "${pkgs.firecracker}/bin/firecracker" "--config-file" configFile "--api-sock" ( @@ -94,7 +95,7 @@ in { then socket else throw "Firecracker must be configured with an API socket (option microvm.socket)!" ) - ]; + ] ++ microvmConfig.firecracker.extraArgs); preStart = '' ${preStart} diff --git a/nixos-modules/microvm/options.nix b/nixos-modules/microvm/options.nix index 4aab449f..fee087fe 100644 --- a/nixos-modules/microvm/options.nix +++ b/nixos-modules/microvm/options.nix @@ -590,6 +590,18 @@ in description = "Custom CPU template passed to firecracker."; }; + firecracker.extraArgs = mkOption { + type = with types; listOf str; + default = []; + description = "Extra arguments to pass to firecracker."; + }; + + firecracker.extraConfig = mkOption { + type = types.attrs; + default = {}; + description = "Extra config to merge into Firecracker JSON configuration"; + }; + prettyProcnames = mkOption { type = types.bool; default = true;