-
Notifications
You must be signed in to change notification settings - Fork 363
/
shell.nix
67 lines (54 loc) · 1.85 KB
/
shell.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ nixpkgs ? (import ./pinned.nix { }),
includeos ? import ./default.nix { },
pkgs ? nixpkgs.pkgsStatic,
llvmPkgs ? pkgs.llvmPackages_16
}:
pkgs.mkShell rec {
stdenv = pkgs.llvmPackages_16.libcxxStdenv;
vmbuild_pkg = nixpkgs.callPackage ./vmbuild.nix {};
packages = [
pkgs.buildPackages.cmake
pkgs.buildPackages.nasm
pkgs.buildPackages.llvmPackages_16.libcxxStdenv.cc
vmbuild_pkg
];
buildInputs = [
pkgs.microsoft_gsl
];
# TODO: Consider moving these to os.cmake, or overlay.nix. The same ones are
# defined in example/default.nix.
libc = "${includeos.musl-includeos}/lib/libc.a";
libcxx = "${includeos.stdenv.cc.libcxx}/lib/libc++.a";
libcxxabi = "${includeos.stdenv.cc.libcxx}/lib/libc++abi.a";
libunwind = "${llvmPkgs.libraries.libunwind}/lib/libunwind.a";
vmbuild = "${vmbuild_pkg}/bin/vmbuild";
linkdeps = [
libc
libcxx
libcxxabi
libunwind
];
shellHook = ''
echo "Nix shell for IncludeOS development."
if [ -z "$INCLUDEOS_PACKAGE" ]; then
echo "INCLUDEOS_PACKAGE must be defined. It can either be a nix package or a cmake install prefix"
exit 1
fi
echo "Validating link-time dependencies: "
for dep in ${toString linkdeps}; do
file $dep
done
echo ""
export CXX=clang++
export CC=clang
export bootloader=$INCLUDEOS_PACKAGE/boot/bootloader
# FIXME: This is pretty bad, maybe use a tempdir.
rm -rf build_example
mkdir build_example
cd build_example
cmake ../example -DARCH=x86_64 -DINCLUDEOS_PACKAGE=$INCLUDEOS_PACKAGE -DINCLUDEOS_LIBC_PATH=${libc} -DINCLUDEOS_LIBCXX_PATH=${libcxx} -DINCLUDEOS_LIBCXXABI_PATH=${libcxxabi} -DINCLUDEOS_LIBUNWIND_PATH=${libunwind}
# This fails for some reason, due to missing libc includes, but works inside the shell;
# $ nix-shell --run "make -j12"
# make -j12
'';
}