-
Notifications
You must be signed in to change notification settings - Fork 389
Expand file tree
/
Copy pathmkUnikernel.nix
More file actions
79 lines (69 loc) · 1.99 KB
/
mkUnikernel.nix
File metadata and controls
79 lines (69 loc) · 1.99 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# mkUnikernel.nix
{ system, default, vmrunner }:
args:
let
ios = if args ? includeos then args.includeos else default;
vmrunnerPkg = if args ? vmrunner then args.vmrunner
else vmrunner.packages.${system}.default;
unikernel = args.unikernel or ./example;
test = args.test or "test.py";
doCheck = args.doCheck or false;
arch = args.arch or "x86_64";
forProduction = args.forProduction or false;
src = unikernel;
in
ios.includeos.stdenv.mkDerivation {
pname = "includeos_unikernel";
version = "dev";
dontStrip = true;
inherit doCheck;
inherit src;
nativeBuildInputs = [
ios.pkgs.buildPackages.nasm
ios.pkgs.buildPackages.cmake
ios.pkgsIncludeOS.suppressTargetWarningHook
];
buildInputs = [
ios.includeos
ios.chainloader
];
cmakeFlags = [
"-DARCH=${arch}"
"-DINCLUDEOS_PACKAGE=${ios.includeos}"
"-DCMAKE_MODULE_PATH=${ios.includeos}/cmake"
"-DFOR_PRODUCTION=${if forProduction then "ON" else "OFF"}"
];
installPhase = ''
runHook preInstall
# we want to place any files required by the test into the output
find -mindepth 1 -maxdepth 1 -type f -exec install -v -D -t "$out/" {} \;
# especially the unikernel image, in case it wasn't at the rootdir already
find -mindepth 2 -name '*.elf.bin' -exec install -v -t "$out/" {} \;
runHook postInstall
'';
nativeCheckInputs = [
vmrunnerPkg
ios.pkgs.grub2
ios.pkgs.python3
ios.pkgs.qemu
ios.pkgs.iputils
ios.pkgs.xorriso
];
checkInputs = [
ios.includeos.lest
];
checkPhase = ''
runHook preCheck
set -e
if [ -e "${src}/${test}" ]; then
echo "Running IncludeOS test: ${src}/${test}"
python3 "${src}/${test}"
else
echo "Default test script '${test}', but no test was found 😟"
echo "For a custom path, consider specifying the path to the test script:"
echo " --argstr test 'path/to/test.py'"
exit 1
fi
runHook postCheck
'';
}