Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/runners/firecracker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let
}.${system};

# Firecracker config, as JSON in `configFile`
config = {
baseConfig = {
boot-source = {
kernel_image_path = kernelPath;
initrd_path = initrdPath;
Expand Down Expand Up @@ -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;

Expand All @@ -86,15 +87,15 @@ 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" (
if socket != null
then socket
else throw "Firecracker must be configured with an API socket (option microvm.socket)!"
)
];
] ++ microvmConfig.firecracker.extraArgs);

preStart = ''
${preStart}
Expand Down
12 changes: 12 additions & 0 deletions nixos-modules/microvm/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That type does not merge. We need to use a submodule of attrs.

default = {};
description = "Extra config to merge into Firecracker JSON configuration";
};

prettyProcnames = mkOption {
type = types.bool;
default = true;
Expand Down