aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/run-firecracker-vm
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-21 16:31:57 +0000
committertv <tv@krebsco.de>2026-11-21 16:50:30 +0000
commit5b918e0b892a3c3eeddd866170eefe2cbd7e6ba3 (patch)
treeecbee40a8bc0c5c189d348d7b8c90af901a15aa9 /pkgs/run-firecracker-vm
parent4148b4543c7d776d3428d01497cfc9de3ae7c9f7 (diff)
run-firecracker-vm: base, modules for the base system, instead of kernelPackages and caCert
The base system could only be changed by its two arguments, and a kernel set in a layer was a conflict with the base's plain boot.kernelPackages = kernelPackages. Now base takes NixOS modules, merged into the base system, i.e. layer 0 and its image, so what all layers share goes there, the kernel above all: kernel.nix is such a module now, and no package any more, so it moves to base/ (--arg base '[ base/kernel.nix ]', like --arg layers '[ layers/nix.nix ]'), and the base's linuxPackages_latest is only a default. A layer can set the kernel, too, now, but then the base image keeps its own kernel's modules (161M for linuxPackages_latest), unused. caCert wasn't used: the egress proxy's CA stays where modules/host puts it, picked up if it's there; another one is security.pki.certificateFiles, in base or a layer.
Diffstat (limited to 'pkgs/run-firecracker-vm')
-rw-r--r--pkgs/run-firecracker-vm/default.nix17
-rw-r--r--pkgs/run-firecracker-vm/kernel.nix35
2 files changed, 10 insertions, 42 deletions
diff --git a/pkgs/run-firecracker-vm/default.nix b/pkgs/run-firecracker-vm/default.nix
index 106ec05..041bf60 100644
--- a/pkgs/run-firecracker-vm/default.nix
+++ b/pkgs/run-firecracker-vm/default.nix
@@ -1,7 +1,9 @@
{ pkgs ? import <nixpkgs> {}
-, kernelPackages ? pkgs.linuxPackages_latest
- # The CA of the host's egress proxy (see modules/host), if it's there.
-, caCert ? "/var/lib/fcbr0-egress/ca.pem"
+ # NixOS modules, part of the base system (layer 0, the first image),
+ # for what all layers share, like the kernel (base/kernel.nix): set in a
+ # layer instead, the base's kernel modules would stay in the base image,
+ # unused.
+, base ? [ ]
# NixOS modules, each a layer on top of the ones before, the first on
# top of the base system (below). The guest runs the top layer's
# system; its store has an image per layer, each with only the store
@@ -155,7 +157,7 @@ let
description = "The secrets the guest needs, by name (--secret NAME=FILE).";
};
}
- ] ++ lib.take n layers;
+ ] ++ base ++ lib.take n layers;
# nix only with layers/nix.nix, which the run script needs to know
# about.
@@ -175,7 +177,7 @@ let
system.stateVersion = lib.trivial.release;
- boot.kernelPackages = kernelPackages;
+ boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
boot.initrd.allowMissingModules = true; # e.g. ahci, efivarfs with a cut-down kernel
boot.initrd.kernelModules = [ "virtio_mmio" "virtio_blk" "erofs" "vmw_vsock_virtio_transport" "9p" "9pnet_fd" "overlay" ];
boot.kernelParams = [
@@ -269,10 +271,11 @@ let
networking.useDHCP = false;
networking.resolvconf.enable = false;
# The host resolves every name to itself and proxies TLS to allowed
- # names, decrypting some with certificates from its CA, see modules/host.
+ # names, decrypting some with certificates from its CA, see modules/host
+ # (if it's there; another one: security.pki.certificateFiles).
environment.etc."resolv.conf".text = "nameserver 172.16.0.1\n";
security.pki.certificateFiles =
- lib.optional (builtins.pathExists caCert) (/. + caCert);
+ lib.optional (builtins.pathExists /var/lib/fcbr0-egress/ca.pem) /var/lib/fcbr0-egress/ca.pem;
systemd.network.enable = true;
systemd.network.wait-online.enable = false;
systemd.network.networks.eth = {
diff --git a/pkgs/run-firecracker-vm/kernel.nix b/pkgs/run-firecracker-vm/kernel.nix
deleted file mode 100644
index cc21e4a..0000000
--- a/pkgs/run-firecracker-vm/kernel.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-# Cut-down guest kernel, based on Firecracker's recommended configuration.
-# usage: nix-build pkgs/run-firecracker-vm \
-# --arg kernelPackages 'import pkgs/run-firecracker-vm/kernel.nix {}'
-{ pkgs ? import <nixpkgs> {} }:
-let
- linux = pkgs.linux_6_18;
-
- firecrackerConfig = pkgs.fetchurl {
- url = "https://raw.githubusercontent.com/firecracker-microvm/firecracker/cc88013eadcf432da1b37d47d445b7e8bcc3046e/resources/guest_configs/microvm-kernel-ci-x86_64-6.18.config";
- sha256 = "05ajrz05kcfk0qa6gvgssazz38flcaji1kgb4k0a94kj1hd408ms";
- };
-
- configfile = pkgs.stdenv.mkDerivation {
- name = "linux-config-${linux.version}-firecracker";
- inherit (linux) src;
- nativeBuildInputs = [ pkgs.bison pkgs.flex ];
- dontConfigure = true;
- buildPhase = ''
- cat ${firecrackerConfig} - > .config <<EOF
- CONFIG_EROFS_FS=m
- CONFIG_NET_9P=m
- CONFIG_9P_FS=m
- EOF
- make olddefconfig
- '';
- installPhase = ''
- cp .config $out
- '';
- };
-in
-pkgs.linuxPackagesFor (pkgs.linuxManualConfig {
- inherit (linux) src version modDirVersion;
- inherit configfile;
- allowImportFromDerivation = true;
-})