1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# Cut-down guest kernel, based on Firecracker's recommended configuration,
# as a module for the base system:
# nix-build pkgs/run-rig --arg base '[ base/kernel.nix ]'
# With erofs and 9P (for the store), KVM as modules, which load when
# the VMM offers hardware virtualization (run-rig --nested),
# and what modules/host needs of nf_tables (inet, IPv6 and bridge
# families, ct count, limit, log, reject, fib, redirect, masquerade), so
# a guest can run guests, too.
{ pkgs, ... }:
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
CONFIG_VIRTUALIZATION=y
CONFIG_KVM=m
CONFIG_KVM_AMD=m
CONFIG_KVM_INTEL=m
CONFIG_NF_TABLES_INET=y
CONFIG_NF_TABLES_IPV6=y
CONFIG_NF_TABLES_BRIDGE=y
CONFIG_NFT_CONNLIMIT=y
CONFIG_NFT_LOG=y
CONFIG_NFT_LIMIT=y
CONFIG_NFT_MASQ=y
CONFIG_NFT_REDIR=y
CONFIG_NFT_REJECT=y
CONFIG_NFT_FIB_IPV4=y
CONFIG_NFT_FIB_IPV6=y
CONFIG_NFT_FIB_INET=y
EOF
make olddefconfig
'';
installPhase = ''
cp .config $out
'';
};
in
{
boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linuxManualConfig {
inherit (linux) src version modDirVersion;
inherit configfile;
allowImportFromDerivation = true;
});
}
|