asterinas/test/initramfs/nix/apps.nix

48 lines
1.3 KiB
Nix
Raw Normal View History

2025-12-15 06:25:32 +00:00
{ lib, stdenv, fetchFromGitHub, hostPlatform, glibc, libnl, callPackage
, testPlatform, }: rec {
2025-09-30 05:58:47 +00:00
tdxAttest = lib.optionalAttrs (builtins.getEnv "INTEL_TDX" == "1")
(callPackage ./tdx-attest.nix { });
2025-07-17 09:37:02 +00:00
mongoose_src = fetchFromGitHub {
2025-07-04 08:37:47 +00:00
owner = "cesanta";
repo = "mongoose";
rev = "7.13";
sha256 = "sha256-9XHUE8SVOG/X7SIB52C8EImPx4XZ7B/5Ojwmb0PkiuI";
};
2025-07-17 09:37:02 +00:00
package = stdenv.mkDerivation {
pname = "apps";
version = "0.1.0";
src = lib.fileset.toSource {
root = ./../src;
fileset = ./../src/apps;
};
MONGOOSE_DIR = "${mongoose_src}";
2025-07-04 08:37:47 +00:00
2025-09-30 05:58:47 +00:00
INTEL_TDX = builtins.getEnv "INTEL_TDX";
TDX_ATTEST_DIR = lib.optionalString (builtins.getEnv "INTEL_TDX" == "1")
"${tdxAttest}/QuoteGeneration";
2025-07-17 09:37:02 +00:00
HOST_PLATFORM = "${hostPlatform.system}";
CC = "${stdenv.cc.targetPrefix}cc";
2025-12-15 06:25:32 +00:00
C_FLAGS = "-I${libnl.dev}/include/libnl3"
+ (if testPlatform == "asterinas" then " -D__asterinas__" else "");
2025-07-17 09:37:02 +00:00
# FIXME: Excluding `glibc` allows the build to succeed, but causes some tests to fail.
buildInputs = [ glibc glibc.static libnl ];
buildCommand = ''
BUILD_DIR=$(mktemp -d)
mkdir -p $BUILD_DIR
cp -r $src/apps $BUILD_DIR/
2025-07-04 08:37:47 +00:00
2025-07-17 09:37:02 +00:00
pushd $BUILD_DIR
make --no-print-directory -C apps
popd
mkdir -p $out
mv build/initramfs/test/* $out/
'';
};
2025-07-04 08:37:47 +00:00
}