-
Notifications
You must be signed in to change notification settings - Fork 3
/
bringYourOwnKernel.nix
50 lines (46 loc) · 1.05 KB
/
bringYourOwnKernel.nix
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
{ lib
, linux_6_8
, buildEnv
, writeShellScriptBin
, busybox
, nitro # this should be nitro-util.lib.${system}
, stdenv
}:
let
myScript = writeShellScriptBin "hello" ''
export PATH="$PATH:${busybox}/bin"
while true;
do
echo "hello there!";
sleep 3;
done
'';
arch = stdenv.hostPlatform.uname.processor;
# use kernel 6.8 with virtio and vsocks
kernel = linux_6_8.override {
structuredExtraConfig = with lib.kernel; {
VIRTIO_MMIO = yes;
VIRTIO_MENU = yes;
VIRTIO_MMIO_CMDLINE_DEVICES = yes;
NET = yes;
VSOCKETS = yes;
VIRTIO_VSOCKETS = yes;
};
ignoreConfigErrors = true;
};
in
nitro.buildEif {
kernel = kernel + (if arch == "aarch64" then "/Image" else "/bzImage");
kernelConfig = kernel.configfile;
name = "eif-hello-world";
# do not include a nsm.ko kernel module, as it is
# already present in Kernel 6.8+
nsmKo = null;
copyToRoot = buildEnv {
name = "image-root";
paths = [ myScript ];
pathsToLink = [ "/bin" ];
};
entrypoint = "/bin/hello";
env = "";
}