add wasi/wamr dependencies

This commit is contained in:
2026-03-12 01:41:43 +01:00
parent 86baf67fac
commit facf04df7f

254
flake.nix
View File

@ -22,7 +22,19 @@ rec {
overlays = []; overlays = [];
}; };
boost174_pkgs = i386_pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [];
# Build crosscompiler
crossSystem = {
config = "i386-elf";
libc = "newlib";
};
};
boost_pkgs =
import (builtins.fetchTarball { import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/824421b1796332ad1bcb35bc7855da832c43305f.tar.gz"; url = "https://github.com/NixOS/nixpkgs/archive/824421b1796332ad1bcb35bc7855da832c43305f.tar.gz";
sha256 = "sha256:1w6cjnakz1yi66rs8c6nmhymsr7bj82vs2hz200ipi1sfiq8dy4y"; sha256 = "sha256:1w6cjnakz1yi66rs8c6nmhymsr7bj82vs2hz200ipi1sfiq8dy4y";
@ -30,6 +42,14 @@ rec {
inherit system; inherit system;
}; };
libdwarf_pkgs =
import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/a054d7450768069084142fe597ed2da367813a4a.tar.gz";
sha256 = "sha256:1wlbz6glkzrl3y7pprw1v4sgkwwzi26qlxqfjzxghdlnny91l3cj";
}) {
inherit system;
};
inherit (pkgs) lib stdenv; inherit (pkgs) lib stdenv;
# ========================================================================================= # =========================================================================================
@ -82,9 +102,6 @@ rec {
# Determine the project root, used e.g. in cmake scripts # Determine the project root, used e.g. in cmake scripts
set -g -x FLAKE_PROJECT_ROOT (git rev-parse --show-toplevel) set -g -x FLAKE_PROJECT_ROOT (git rev-parse --show-toplevel)
# Rust Bevy:
# abbr -a build-release-windows "CARGO_FEATURE_PURE=1 cargo xwin build --release --target x86_64-pc-windows-msvc"
# C/C++: # C/C++:
# abbr -a cmake-debug "${cmakeDebug}" # abbr -a cmake-debug "${cmakeDebug}"
# abbr -a cmake-release "${cmakeRelease}" # abbr -a cmake-release "${cmakeRelease}"
@ -111,14 +128,12 @@ rec {
pyyaml pyyaml
]); ]);
boost174 = boost174_pkgs.boost174;
libpcl = stdenv.mkDerivation rec { libpcl = stdenv.mkDerivation rec {
pname = "libpcl1"; pname = "libpcl1";
version = "1.12-2"; version = "1.12-2";
src = pkgs.fetchurl { src = pkgs.fetchurl {
url = "http://launchpadlibrarian.net/521269537/libpcl1_1.12-2_amd64.deb"; url = "http://launchpadlibrarian.net/521269537/${pname}_${version}_amd64.deb";
hash = "sha256-GL3mjPAccAtRMAJPnDMCHiDf6xNvGi4oUWylOIqBjP0="; hash = "sha256-GL3mjPAccAtRMAJPnDMCHiDf6xNvGi4oUWylOIqBjP0=";
}; };
@ -131,9 +146,6 @@ rec {
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
ls -al
# dpkg-deb -x ${pname}_${version}_amd64.deb libpcl
mkdir -p $out/lib mkdir -p $out/lib
cp -rv usr/lib/x86_64-linux-gnu/* $out/lib/ cp -rv usr/lib/x86_64-linux-gnu/* $out/lib/
@ -141,6 +153,170 @@ rec {
''; '';
}; };
wasi-sdk = stdenv.mkDerivation rec {
pname = "wasi-sdk";
version = "29";
src = let
baseurl = "https://github.com/WebAssembly/wasi-sdk/releases/download";
in
builtins.fetchTarball {
url = "${baseurl}/${pname}-${version}/${pname}-${version}.0-x86_64-linux.tar.gz";
sha256 = "sha256:16afis71iqfvwiny4dz0lk9f7wbary0wa67ybwyhywr8g57ss6hq";
};
nativeBuildInputs = with pkgs; [
autoPatchelfHook
];
buildInputs = with pkgs; [
libgcc.lib
];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out
cp -rv ./* $out/
runHook postInstall
'';
};
iwasm = stdenv.mkDerivation rec {
pname = "iwasm";
version = "2.4.4";
src = let
baseurl = "https://github.com/bytecodealliance/wasm-micro-runtime/releases/download";
in
builtins.fetchTarball {
url = "${baseurl}/WAMR-${version}/${pname}-${version}-x86_64-ubuntu-22.04.tar.gz";
sha256 = "sha256:05irihz3yf7hpc0a59qz9i62imhrsni9xy9nxwsn6b8s92c1yzrp";
};
nativeBuildInputs = with pkgs; [
autoPatchelfHook
];
buildInputs = with pkgs; [
libz
zstd
libgcc.lib
];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp -rv ./* $out/bin/
runHook postInstall
'';
};
wamrc = stdenv.mkDerivation rec {
pname = "wamrc";
version = "2.4.4";
src = let
baseurl = "https://github.com/bytecodealliance/wasm-micro-runtime/releases/download";
in
builtins.fetchTarball {
url = "${baseurl}/WAMR-${version}/${pname}-${version}-x86_64-ubuntu-22.04.tar.gz";
sha256 = "sha256:0264arh03gc35z0zdvw07qdvqgfvsxr3qgl1aszghwicmdmh4sqj";
};
nativeBuildInputs = with pkgs; [
autoPatchelfHook
];
buildInputs = with pkgs; [
libz
zstd
libgcc.lib
];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp -rv ./* $out/bin/
runHook postInstall
'';
};
wamr = stdenv.mkDerivation rec {
pname = "wamr";
version = "2.4.4";
src = pkgs.fetchFromGitea {
domain = "gitea.local.chriphost.de";
owner = "christoph";
repo = "wamr";
rev = "fd69a4e76ec0d384bd79f514772b7dfa240fc0d7";
hash = "sha256-rlCx4isI0k6rC9E0hWIA9LeinqiACug7zxj9z/e4SBQ=";
};
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out
cp -rv ./* $out/
runHook postInstall
'';
};
libiwasm = buildtype: flags:
i386_pkgs.stdenv.mkDerivation rec {
pname = "libiwasm";
version = "2.4.4";
src = pkgs.fetchFromGitea {
domain = "gitea.local.chriphost.de";
owner = "christoph";
repo = "wamr";
rev = "fd69a4e76ec0d384bd79f514772b7dfa240fc0d7";
hash = "sha256-rlCx4isI0k6rC9E0hWIA9LeinqiACug7zxj9z/e4SBQ=";
};
nativeBuildInputs = with pkgs; [cmake];
cmakeBuildType = buildtype;
cmakeFlags = [
"-DCMAKE_SYSTEM_NAME=Generic"
"-DCMAKE_SYSTEM_PROCESSOR=i386"
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
"-DCMAKE_VERBOSE_MAKEFILE=ON"
"-DCMAKE_COLOR_DIAGNOSTICS=ON"
"-DWAMR_BUILD_PLATFORM=baremetal"
"-DWAMR_BUILD_TARGET=X86_32"
"-DWAMR_BUILD_AOT=1"
"-DWAMR_BUILD_WAMR_COMPILER=0"
"-DWAMR_BUILD_INTERP=1"
"-DWAMR_BUILD_FAST_INTERP=0"
"-DWAMR_BUILD_JIT=0"
"-DWAMR_BUILD_FAST_JIT=0"
"-DWAMR_BUILD_LIBC_BUILTIN=1"
"-DWAMR_BUILD_LIBC_WASI=0"
"-DWAMR_BUILD_SIMD=0"
];
# Since GCC 15, implicit declarations are an error. Disable this.
NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration " + flags;
};
libiwasm_debug = libiwasm "Debug" "-O0 -ggdb";
libiwasm_release = libiwasm "Release" "-O2 -DNDEBUG";
# =========================================================================================== # ===========================================================================================
# Specify dependencies # Specify dependencies
# https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies-overview # https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies-overview
@ -149,7 +325,7 @@ rec {
# Add dependencies to nativeBuildInputs if they are executed during the build: # Add dependencies to nativeBuildInputs if they are executed during the build:
# - Those which are needed on $PATH during the build, for example cmake and pkg-config # - Those which are needed on $PATH during the build, for example cmake and pkg-config
# - Setup hooks, for example makeWrapper # - Setup hooks, for example makeWrapper/autoPatchelfHook
# - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl # - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
autoPatchelfHook autoPatchelfHook
@ -159,25 +335,27 @@ rec {
# - Libraries used by compilers, for example zlib # - Libraries used by compilers, for example zlib
# - Interpreters needed by patchShebangs for scripts which are installed, which can be the case for e.g. perl # - Interpreters needed by patchShebangs for scripts which are installed, which can be the case for e.g. perl
buildInputs = with pkgs; [ buildInputs = with pkgs; [
python # For resultbrowser # FAIL runtime dependencies
python # bochs-experiment-runner.py, resultbrowser.py
alsa-lib # libasound.so.2 alsa-lib # libasound.so.2
boost174 # libboost_coroutine.so.1.74.0, libboost_regex.so.1.74.0, libboost_thread.so.1.74.0 boost_pkgs.boost174 # libboost_coroutine.so.1.74.0, libboost_regex.so.1.74.0, libboost_thread.so.1.74.0
capstone_4 # libcapstone.so.4 capstone_4 # libcapstone.so.4
libdwarf # libdwarf.so.1 libdwarf_pkgs.libdwarf # libdwarf.so.1
libelf # libelf.so.1 elfutils # libelf.so.1
mariadb-connector-c # libmariadb.so.3 mariadb # libmariadb.so.3
libpcl # libpcl.so.1 libpcl # libpcl.so.1
protobuf # libprotobuf.so.32 protobuf_21 # libprotobuf.so.32
SDL # libSDL-1.2.so.0 SDL # libSDL-1.2.so.0
libx11 # libX11.so.6 libx11 # libX11.so.6
libxrandr # libXrandr.so.2 libxrandr # libXrandr.so.2
libz # libz.so.1 libz # libz.so.1
]; ];
# =========================================================================================== # ===========================================================================================
# Define buildable + installable packages # Define buildable + installable packages
# =========================================================================================== # ===========================================================================================
package = stdenv.mkDerivation rec {
fail-bin = stdenv.mkDerivation {
inherit nativeBuildInputs buildInputs; inherit nativeBuildInputs buildInputs;
pname = "fail"; pname = "fail";
version = "1.0.0"; version = "1.0.0";
@ -193,26 +371,54 @@ rec {
runHook postInstall runHook postInstall
''; '';
}; };
in rec { in {
# Provide package for "nix build" # Provide package for "nix build"
packages = { packages = {
default = package; default = fail-bin;
};
apps = {
default = flake-utils.lib.mkApp {drv = fail-bin;};
}; };
apps.default = flake-utils.lib.mkApp {drv = package;};
devShells = { devShells = {
# Provide default environment for "nix develop". # Provide default environment for "nix develop".
# Other environments can be added below. # Other environments can be added below.
default = pkgs.mkShell { default = pkgs.mkShell {
inherit nativeBuildInputs buildInputs shellHook; inherit shellHook;
name = description; name = description;
nativeBuildInputs = with pkgs; [
just
xxd
wabt
grub2
xorriso
mariadb.client
iwasm
wamrc
fail-bin
# Don't install to not pollute our PATH. Just export as environment variable.
# wasi-sdk
# libiwasm_debug
# libiwasm_release
];
# ========================================================================================= # =========================================================================================
# Define environment variables # Define environment variables
# ========================================================================================= # =========================================================================================
# Dynamic libraries from buildinputs: # Dynamic libraries from buildinputs:
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; # LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
# Those are read by the justfile
FAIL_SHARE = "${fail-bin}/share";
WASI_ROOT = wasi-sdk;
WAMR_ROOT = wamr;
LIBIWASM_DEBUG = "${libiwasm_debug}/lib";
LIBIWASM_RELEASE = "${libiwasm_release}/lib";
CROSSCC = "${i386_pkgs.buildPackages.gcc}/bin/i386-elf-gcc";
CROSSCXX = "${i386_pkgs.buildPackages.gcc}/bin/i386-elf-g++";
}; };
}; };
}); });