Skip to content

Commit 1134176

Browse files
committed
nix: simplify shell
- add includeos to buildInputs to enable cmake find_package - use includeos overlay pointers to chainloader and vmrunner, use includeos.pkgs - remove now unused imports pkgs and nixpkgs - remove INCLUDEOS_VMRUNNER and INCLUDEOS_CHAINLOADER as they are no longer needed by vmrunner - inherit stdenv from overlay instead of setting CC/CXX manually - bash: add quotes around unikernel and buildpath
1 parent 9cd1c69 commit 1134176

1 file changed

Lines changed: 27 additions & 44 deletions

File tree

shell.nix

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,39 @@
1515
# Enable multicore suport.
1616
smp ? false,
1717

18-
nixpkgs ? ./pinned.nix,
19-
overlays ? [ (import ./overlay.nix { inherit withCcache; inherit smp; }) ],
20-
chainloader ? (import ./chainloader.nix { inherit withCcache; }),
21-
pkgs ? import nixpkgs {
22-
config = {};
23-
inherit overlays;
24-
},
18+
includeos ? import ./default.nix { inherit withCcache; inherit smp; }
19+
2520
}:
26-
pkgs.mkShell rec {
27-
includeos = pkgs.pkgsIncludeOS.includeos;
28-
stdenv = pkgs.pkgsIncludeOS.stdenv;
2921

22+
includeos.pkgs.mkShell.override { inherit (includeos) stdenv; } rec {
3023
vmrunnerPkg =
3124
if vmrunner == "" then
32-
pkgs.callPackage (builtins.fetchGit {
33-
url = "https://github.com/includeos/vmrunner";
34-
}) {}
25+
includeos.vmrunner
3526
else
36-
pkgs.callPackage (builtins.toPath /. + vmrunner) {};
37-
38-
lest = pkgs.callPackage ./deps/lest {};
27+
includeos.pkgs.callPackage (builtins.toPath /. + vmrunner) {};
3928

4029
packages = [
41-
vmrunnerPkg
42-
stdenv.cc
43-
pkgs.buildPackages.cmake
44-
pkgs.buildPackages.nasm
45-
pkgs.qemu
46-
pkgs.which
47-
pkgs.grub2
48-
pkgs.iputils
30+
(includeos.pkgs.python3.withPackages (p: [
31+
vmrunnerPkg
32+
]))
33+
includeos.pkgs.buildPackages.cmake
34+
includeos.pkgs.buildPackages.nasm
35+
includeos.pkgs.qemu
36+
includeos.pkgs.which
37+
includeos.pkgs.grub2
38+
includeos.pkgs.iputils
39+
includeos.pkgs.xorriso
4940
];
5041

5142
buildInputs = [
52-
chainloader
53-
lest
54-
pkgs.openssl
55-
pkgs.rapidjson
56-
pkgs.xorriso
43+
includeos
44+
includeos.chainloader
45+
includeos.lest
46+
includeos.pkgs.openssl
47+
includeos.pkgs.rapidjson
5748
];
5849

59-
bootloader="${includeos}/boot/bootloader";
60-
6150
shellHook = ''
62-
CC=${stdenv.cc}/bin/clang
63-
CXX=${stdenv.cc}/bin/clang++
64-
65-
# The 'boot' utility in the vmrunner package requires these env vars
66-
export INCLUDEOS_VMRUNNER=${vmrunnerPkg}
67-
export INCLUDEOS_CHAINLOADER=${chainloader}/bin
6851
6952
unikernel=$(realpath ${unikernel})
7053
echo -e "Attempting to build unikernel: \n$unikernel"
@@ -74,13 +57,13 @@ pkgs.mkShell rec {
7457
fi
7558
export BUILDPATH=${buildpath}
7659
if [ -z "${buildpath}" ]; then
77-
export BUILDPATH=$(mktemp -d)
78-
pushd $BUILDPATH
60+
export BUILDPATH="$(mktemp -d)"
61+
pushd "$BUILDPATH"
7962
else
80-
mkdir -p $BUILDPATH
81-
pushd $BUILDPATH
63+
mkdir -p "$BUILDPATH"
64+
pushd "$BUILDPATH"
8265
fi
83-
cmake $unikernel -DARCH=x86_64 -DINCLUDEOS_PACKAGE=${includeos} -DCMAKE_MODULE_PATH=${includeos}/cmake \
66+
cmake "$unikernel" -DARCH=x86_64 -DINCLUDEOS_PACKAGE=${includeos} -DCMAKE_MODULE_PATH=${includeos}/cmake \
8467
-DFOR_PRODUCTION=OFF
8568
make -j $NIX_BUILD_CORES
8669
echo -e "\n====================== IncludeOS nix-shell ====================="
@@ -98,15 +81,15 @@ pkgs.mkShell rec {
9881
echo "The vmrunner for IncludeOS tests requires bridged networking for full functionality."
9982
echo "The following commands requiring sudo privileges can be used to set this up:"
10083
echo "1. the qemu-bridge-helper needs sudo to create a bridge. Can be enabled with:"
101-
echo " sudo chmod u+s ${pkgs.qemu}/libexec/qemu-bridge-helper"
84+
echo " sudo chmod u+s ${includeos.pkgs.qemu}/libexec/qemu-bridge-helper"
10285
echo "2. bridge43 must exist. Can be set up with vmrunner's create_bridge.sh script:"
10386
echo " ${vmrunnerPkg.create_bridge}"
10487
echo "3. /etc/qemu/bridge.conf must contain this line:"
10588
echo " allow bridge43"
10689
echo ""
10790
echo "Some tests require ping, which requires premissions to send raw packets. On some hosts"
10891
echo "this is not enabled by default for iputils provided by nix. It can be enabled with:"
109-
echo "4. sudo setcap cap_net_raw+ep ${pkgs.iputils}/bin/ping"
92+
echo "4. sudo setcap cap_net_raw+ep ${includeos.pkgs.iputils}/bin/ping"
11093
echo " "
11194
echo
11295
'';

0 commit comments

Comments
 (0)