Skip to content
Open
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
5 changes: 4 additions & 1 deletion chainloader.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
let
includeos = pkgs.pkgsIncludeOS.includeos;
stdenv = pkgs.pkgsIncludeOS.stdenv;

suppress = includeos.pkgs.callPackage ./nix/suppress.nix {};
ccache = includeos.pkgs.callPackage ./nix/ccache.nix {};
in

assert (stdenv.targetPlatform.system != "i686-linux") ->
Expand Down Expand Up @@ -48,5 +51,5 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
pkgs.buildPackages.cmake
pkgs.buildPackages.nasm
] ++ [ pkgs.pkgsIncludeOS.suppressTargetWarningHook ];
] ++ [ suppress.targetWarningHook ];
}
54 changes: 54 additions & 0 deletions nix/ccache.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{ pkgs
, cc
, ccacheDir ? "/nix/var/cache/ccache"
, showNotice ? true
}:
let
noticeHook =
if showNotice then
pkgs.writeTextFile {
name = "ccache-notice-hook";
destination = "/nix-support/setup-hook";
text = ''
echo "====="
echo "ccache is enabled!"
echo "Disable with: --arg withCcache false"
echh ""
echo "It's recommended to run tests with ccache disabled to avoid cache incoherencies."
echo "====="
'';
}
else
null;

wrapper = pkgs.ccacheWrapper.override {
inherit cc;

extraConfig = ''
export CCACHE_DIR="${ccacheDir}"
if [ ! -d "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' does not exist"
echo " sudo mkdir -m0770 '$CCACHE_DIR'
echo "sudo chown root:nixbld '$CCACHE_DIR'"
echo ""
echo 'Alternatively, disable ccache with `--arg withCcache false`'
echo "====="
exit 1
fi
if [ ! -w "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' exists but isn't writable by $(whoami)"
echo "Please verify its access permissions"
echo "====="
exit 1
fi
export CCACHE_COMPRESS=1
export CCACHE_UMASK=007
export CCACHE_SLOPPINESS=random_seed
'';
};
in
{
inherit wrapper noticeHook;
}
16 changes: 16 additions & 0 deletions nix/suppress.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ pkgs }:
let
targetWarningHook = pkgs.writeTextFile {
name = "suppress-target-warning-hook";
destination = "/nix-support/setup-hook";
text = ''
# see https://github.com/NixOS/nixpkgs/issues/395191
# delete this hook and downstream references once resolved

export NIX_CC_WRAPPER_SUPPRESS_TARGET_WARNING=1
'';
};
in
{
inherit targetWarningHook;
}
58 changes: 4 additions & 54 deletions overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,32 +59,12 @@ final: prev: {

pkgsIncludeOS = prev.pkgsStatic.lib.makeScope prev.pkgsStatic.newScope (self:
let
ccacheNoticeHook = prev.writeTextFile {
name = "ccache-notice-hook";
destination = "/nix-support/setup-hook";
text = ''
echo "====="
echo "ccache is enabled!"
echo "If you run into any issues, try: --arg withCcache false"
echo "It's recommended to run tests with ccache disabled to avoid cache incoherencies."
echo "====="
'';
};

suppressTargetWarningHook = prev.writeTextFile {
name = "suppress-target-warning-hook";
destination = "/nix-support/setup-hook";
text = ''
# see https://github.com/NixOS/nixpkgs/issues/395191
# delete this hook and downstream references once resolved
ccache = import ./nix/ccache.nix { pkgs = prev; inherit (self.stdenv) cc; };

export NIX_CC_WRAPPER_SUPPRESS_TARGET_WARNING=1
'';
};
suppress = import ./nix/suppress.nix { pkgs = prev; };
in {
# self.callPackage will use this stdenv.
stdenv = final.stdenvIncludeOS.includeos_stdenv;
inherit suppressTargetWarningHook;

# Deps
botan2 = self.callPackage ./deps/botan/default.nix { };
Expand All @@ -95,36 +75,6 @@ final: prev: {

vmbuild = self.callPackage ./vmbuild.nix { };

ccacheWrapper = prev.ccacheWrapper.override {
inherit (self.stdenv) cc;
extraConfig = ''
export CCACHE_DIR="/nix/var/cache/ccache"
if [ ! -d "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' does not exist"
echo "Please create it with:"
echo " sudo mkdir -m0770 '$CCACHE_DIR'"
echo " sudo chown root:nixbld '$CCACHE_DIR'"
echo ""
echo 'Alternatively, disable ccache with `--arg withCcache false`'
echo "====="
exit 1
fi
if [ ! -w "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' exists, but is not accessible for user $(whoami)"
echo "Please verify its access permissions"
echo 'Alternatively, disable ccache with `--arg withCcache false`'
echo "====="
exit 1
fi

export CCACHE_COMPRESS=1
export CCACHE_UMASK=007
export CCACHE_SLOPPINESS=random_seed
'';
};

# IncludeOS
includeos = self.stdenv.mkDerivation rec {
enableParallelBuilding = true;
Expand Down Expand Up @@ -155,8 +105,8 @@ final: prev: {
nativeBuildInputs = [
prev.buildPackages.cmake
prev.buildPackages.nasm
] ++ prev.lib.optionals disableTargetWarning [suppressTargetWarningHook]
++ prev.lib.optionals withCcache [self.ccacheWrapper ccacheNoticeHook];
] ++ prev.lib.optionals disableTargetWarning [suppress.targetWarningHook]
++ prev.lib.optionals withCcache [ccache.wrapper ccache.noticeHook];

buildInputs = [
self.libfmt
Expand Down
5 changes: 4 additions & 1 deletion unikernel.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ let
includeos.vmrunner
else
includeos.pkgs.callPackage (builtins.toPath /. + vmrunner) {};

suppress = includeos.pkgs.callPackage ./nix/suppress.nix {};
ccache = includeos.pkgs.callPackage ./nix/ccache.nix {};
in
includeos.stdenv.mkDerivation rec {
pname = "includeos_example";
Expand All @@ -49,7 +52,7 @@ includeos.stdenv.mkDerivation rec {
nativeBuildInputs = [
includeos.pkgs.buildPackages.nasm
includeos.pkgs.buildPackages.cmake
] ++ [ includeos.pkgs.pkgsIncludeOS.suppressTargetWarningHook ];
] ++ [ suppress.targetWarningHook ];

buildInputs = [
includeos
Expand Down
33 changes: 5 additions & 28 deletions unittests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,22 @@
stdenv ? pkgs.llvmPackages_19.libcxxStdenv,
withCcache ? false,
}:
let
ccache = pkgs.callPackage ./nix/ccache.nix { };
in
stdenv.mkDerivation rec {
pname = "unittests";
version = "dev";
enableParallelBuilding = true;

sourceRoot = "test";

ccacheWrapper = pkgs.ccacheWrapper.override {
inherit (stdenv) cc;
extraConfig = ''
export CCACHE_COMPRESS=1
export CCACHE_DIR="/nix/var/cache/ccache"
export CCACHE_UMASK=007
export CCACHE_SLOPPINESS=random_seed
if [ ! -d "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' does not exist"
echo "Please create it with:"
echo " sudo mkdir -m0770 '$CCACHE_DIR'"
echo " sudo chown root:nixbld '$CCACHE_DIR'"
echo "====="
exit 1
fi
if [ ! -w "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
echo "Please verify its access permissions"
echo "====="
exit 1
fi
'';
};

srcs = [
./test
./src
./api
./lib
];
];

hardeningDisable = [ "all" ];
cmakeBuildType = "Debug";
Expand All @@ -59,7 +36,7 @@ stdenv.mkDerivation rec {
pkgs.buildPackages.cmake
pkgs.buildPackages.valgrind
pkgs.buildPackages.clang-tools
] ++ pkgs.lib.optionals withCcache [ccacheWrapper];
] ++ pkgs.lib.optionals withCcache [ccache.wrapper];

buildInputs = [
pkgs.rapidjson
Expand Down