From b6c5f9c5008463f0769e4c6b70aa0a26c98c9fbb Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Fri, 7 Nov 2025 13:42:11 +0000 Subject: [PATCH 1/2] firecracker: Add extraConfig option For experimentation with low-level settings, add support for merging in arbitrary options to the Firecracker config file, following the standard pattern in nixpkgs for this kind of thing. My immediate usecase for this is for experimenting with firecracker features that are not yet released, so it doesn't make sense to add more specific Nix options for those features. --- lib/runners/firecracker.nix | 3 ++- nixos-modules/microvm/options.nix | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/runners/firecracker.nix b/lib/runners/firecracker.nix index a73f97fb..d60d2c77 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; diff --git a/nixos-modules/microvm/options.nix b/nixos-modules/microvm/options.nix index 4aab449f..4e7a7b98 100644 --- a/nixos-modules/microvm/options.nix +++ b/nixos-modules/microvm/options.nix @@ -590,6 +590,12 @@ in description = "Custom CPU template passed 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; From 2c0e70ee0c7d36902e6f2fd6d523dedfb5e51846 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Mon, 10 Nov 2025 15:20:49 +0000 Subject: [PATCH 2/2] fireracker: Add extraArgs option For experimentation, support adding arbitrary extra args. --- lib/runners/firecracker.nix | 4 ++-- nixos-modules/microvm/options.nix | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/runners/firecracker.nix b/lib/runners/firecracker.nix index d60d2c77..356898cd 100644 --- a/lib/runners/firecracker.nix +++ b/lib/runners/firecracker.nix @@ -87,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" ( @@ -95,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 4e7a7b98..fee087fe 100644 --- a/nixos-modules/microvm/options.nix +++ b/nixos-modules/microvm/options.nix @@ -590,6 +590,12 @@ 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 = {};