Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chainloader.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ stdenv.mkDerivation rec {

sourceRoot = "./src/chainload/";

cmakeFlags = [
"-DINCLUDEOS_PACKAGE=${includeos}"
buildInputs = [
includeos
];

srcs = [
Expand Down
22 changes: 15 additions & 7 deletions example.nix
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
{ withCcache ? false,

nixpkgs ? ./pinned.nix,
doCheck ? true, # boot unikernel after building it
includeos ? import ./default.nix { inherit withCcache; },
pkgs ? (import nixpkgs { }).pkgsStatic,
llvmPkgs ? pkgs.llvmPackages_18
}:

includeos.stdenv.mkDerivation rec {
pname = "includeos_example";
src = pkgs.lib.cleanSource ./example;
doCheck = false;
src = includeos.pkgs.lib.cleanSource ./example;
dontStrip = true;
inherit doCheck;

nativeBuildInputs = [
pkgs.buildPackages.nasm
pkgs.buildPackages.cmake
includeos.pkgs.buildPackages.nasm
includeos.pkgs.buildPackages.cmake
];

buildInputs = [
includeos
includeos.chainloader
];

nativeCheckInputs = [
includeos.vmrunner
includeos.pkgs.qemu
];

checkPhase = ''
boot *.elf.bin
'';

version = "dev";
}
11 changes: 10 additions & 1 deletion overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,17 @@ final: prev: {

cmakeFlags = archFlags ++ smpFlags;

# Add some pasthroughs, for easily building the depdencies (for debugging):
# Add some pasthroughs, for easily building the dependencies (for debugging):
# $ nix-build -A NAME

passthru.vmrunner = prev.callPackage (builtins.fetchGit {
url = "https://github.com/includeos/vmrunner";
}) {};
passthru.chainloader = import ./chainloader.nix { inherit withCcache; };
passthru.lest = self.callPackage ./deps/lest {};
passthru.pkgsStatic = prev.pkgsStatic; # this is for convenience for other packages that depend on includeos
passthru.pkgs = prev.pkgs; # this is for convenience for other packages that depend on includeos

passthru = {
inherit (self) uzlib;
inherit (self) http-parser;
Expand Down
71 changes: 27 additions & 44 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,39 @@
# Enable multicore suport.
smp ? false,

nixpkgs ? ./pinned.nix,
overlays ? [ (import ./overlay.nix { inherit withCcache; inherit smp; }) ],
chainloader ? (import ./chainloader.nix { inherit withCcache; }),
pkgs ? import nixpkgs {
config = {};
inherit overlays;
},
includeos ? import ./default.nix { inherit withCcache; inherit smp; }

}:
pkgs.mkShell rec {
includeos = pkgs.pkgsIncludeOS.includeos;
stdenv = pkgs.pkgsIncludeOS.stdenv;

includeos.pkgs.mkShell.override { inherit (includeos) stdenv; } rec {
vmrunnerPkg =
if vmrunner == "" then
pkgs.callPackage (builtins.fetchGit {
url = "https://github.com/includeos/vmrunner";
}) {}
includeos.vmrunner
else
pkgs.callPackage (builtins.toPath /. + vmrunner) {};

lest = pkgs.callPackage ./deps/lest {};
includeos.pkgs.callPackage (builtins.toPath /. + vmrunner) {};

packages = [
vmrunnerPkg
stdenv.cc
pkgs.buildPackages.cmake
pkgs.buildPackages.nasm
pkgs.qemu
pkgs.which
pkgs.grub2
pkgs.iputils
(includeos.pkgs.python3.withPackages (p: [
vmrunnerPkg
]))
includeos.pkgs.buildPackages.cmake
includeos.pkgs.buildPackages.nasm
includeos.pkgs.qemu
includeos.pkgs.which
includeos.pkgs.grub2
includeos.pkgs.iputils
includeos.pkgs.xorriso
];

buildInputs = [
chainloader
lest
pkgs.openssl
pkgs.rapidjson
pkgs.xorriso
includeos
includeos.chainloader
includeos.lest
includeos.pkgs.openssl
includeos.pkgs.rapidjson
];

bootloader="${includeos}/boot/bootloader";

shellHook = ''
CC=${stdenv.cc}/bin/clang
CXX=${stdenv.cc}/bin/clang++

# The 'boot' utility in the vmrunner package requires these env vars
export INCLUDEOS_VMRUNNER=${vmrunnerPkg}
export INCLUDEOS_CHAINLOADER=${chainloader}/bin

unikernel=$(realpath ${unikernel})
echo -e "Attempting to build unikernel: \n$unikernel"
Expand All @@ -74,13 +57,13 @@ pkgs.mkShell rec {
fi
export BUILDPATH=${buildpath}
if [ -z "${buildpath}" ]; then
export BUILDPATH=$(mktemp -d)
pushd $BUILDPATH
export BUILDPATH="$(mktemp -d)"
pushd "$BUILDPATH"
else
mkdir -p $BUILDPATH
pushd $BUILDPATH
mkdir -p "$BUILDPATH"
pushd "$BUILDPATH"
fi
cmake $unikernel -DARCH=x86_64 -DINCLUDEOS_PACKAGE=${includeos} -DCMAKE_MODULE_PATH=${includeos}/cmake \
cmake "$unikernel" -DARCH=x86_64 -DINCLUDEOS_PACKAGE=${includeos} -DCMAKE_MODULE_PATH=${includeos}/cmake \
-DFOR_PRODUCTION=OFF
make -j $NIX_BUILD_CORES
echo -e "\n====================== IncludeOS nix-shell ====================="
Expand All @@ -98,15 +81,15 @@ pkgs.mkShell rec {
echo "The vmrunner for IncludeOS tests requires bridged networking for full functionality."
echo "The following commands requiring sudo privileges can be used to set this up:"
echo "1. the qemu-bridge-helper needs sudo to create a bridge. Can be enabled with:"
echo " sudo chmod u+s ${pkgs.qemu}/libexec/qemu-bridge-helper"
echo " sudo chmod u+s ${includeos.pkgs.qemu}/libexec/qemu-bridge-helper"
echo "2. bridge43 must exist. Can be set up with vmrunner's create_bridge.sh script:"
echo " ${vmrunnerPkg.create_bridge}"
echo "3. /etc/qemu/bridge.conf must contain this line:"
echo " allow bridge43"
echo ""
echo "Some tests require ping, which requires premissions to send raw packets. On some hosts"
echo "this is not enabled by default for iputils provided by nix. It can be enabled with:"
echo "4. sudo setcap cap_net_raw+ep ${pkgs.iputils}/bin/ping"
echo "4. sudo setcap cap_net_raw+ep ${includeos.pkgs.iputils}/bin/ping"
echo " "
echo
'';
Expand Down
6 changes: 4 additions & 2 deletions src/chainload/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.6)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# IncludeOS install location
project(chainloader C CXX)

find_package(IncludeOS REQUIRED)

set(ARCH i686)
set(PLATFORM nano)
set(ELF_SYMBOLS true)

include(${INCLUDEOS_PACKAGE}/cmake/os.cmake)
include(os)

option(default_stdout "" ON)
set(SOURCES
Expand Down