Compare commits

...

2 Commits

Author SHA1 Message Date
18e1407254 remove flake.nix 2026-01-25 19:47:34 +01:00
e0c6be3270 dockerfile: update image tags 2026-01-25 19:47:27 +01:00
6 changed files with 6 additions and 399 deletions

59
flake.lock generated
View File

@ -1,59 +0,0 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1768032153,
"narHash": "sha256-6kD1MdY9fsE6FgSwdnx29hdH2UcBKs3/+JJleMShuJg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3146c6aa9995e7351a398e17470e15305e6e18ff",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

334
flake.nix
View File

@ -1,334 +0,0 @@
rec {
description = "FAIL* - Fault Injection Leveraged";
inputs = {
nixpkgs.url = "nixpkgs"; # Use nixpkgs from system registry
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}:
# Create a shell (and possibly package) for each possible system, not only x86_64-linux
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [];
};
inherit (pkgs) lib stdenv;
# ===========================================================================================
# Define custom dependencies
# ===========================================================================================
# 64 bit C/C++ compilers that don't collide (use the same libc)
bintools = pkgs.wrapBintoolsWith {
bintools = pkgs.bintools.bintools; # Unwrapped bintools
libc = pkgs.glibc;
};
gcc = lib.hiPrio (pkgs.wrapCCWith {
cc = pkgs.gcc.cc; # Unwrapped gcc
libc = pkgs.glibc;
bintools = bintools;
});
clang = pkgs.wrapCCWith {
cc = pkgs.clang.cc; # Unwrapped clang
libc = pkgs.glibc;
bintools = bintools;
};
# Multilib C/C++ compilers that don't collide (use the same libc)
# bintools_multilib = pkgs.wrapBintoolsWith {
# bintools = pkgs.bintools.bintools; # Unwrapped bintools
# libc = pkgs.glibc_multi;
# };
# gcc_multilib = lib.hiPrio (pkgs.wrapCCWith {
# cc = pkgs.gcc.cc; # Unwrapped gcc
# libc = pkgs.glibc_multi;
# bintools = bintools_multilib;
# });
# clang_multilib = pkgs.wrapCCWith {
# cc = pkgs.clang.cc; # Unwrapped clang
# libc = pkgs.glibc_multi;
# bintools = bintools_multilib;
# };
aspectcxx = stdenv.mkDerivation rec {
pname = "aspectcxx";
version = "1.2";
src = pkgs.fetchurl {
url = "http://www.aspectc.org/releases/${version}/ac-bin-linux-x86-64bit-${version}.tar.gz";
sha256 = "sha256-8wOrPYC99E3aV5/Js2EBI4V/OoD9y10fYZt8ikPtvt4="; # 1.2
# sha256 = "sha256-gmqoZFkPvs60b6yuMHNtYvuGJXGnbwAYEiyXxp/fmPI="; # 2.0
# sha256 = "sha256-+rEflemXNwn4XZZwSOqCsr6/KFGV8wxW6PeXzHHUK0o="; # 2.5
};
nativeBuildInputs = [
pkgs.autoPatchelfHook
];
unpackPhase = ''
tar xvzf $src
'';
installPhase = ''
mkdir -p $out/bin
cp aspectc++/ac++ $out/bin/
cp aspectc++/ag++ $out/bin/
'';
};
libpcl = stdenv.mkDerivation rec {
pname = "libpcl";
version = "1.12-2";
src = pkgs.fetchurl {
url = "https://launchpadlibrarian.net/521269537/libpcl1_1.12-2_amd64.deb";
sha256 = "sha256-GL3mjPAccAtRMAJPnDMCHiDf6xNvGi4oUWylOIqBjP0=";
};
nativeBuildInputs = with pkgs; [
dpkg
autoPatchelfHook
];
unpackPhase = ''
dpkg-deb -x $src .
'';
installPhase = ''
mkdir -p $out
cp -r usr/* $out/
'';
};
libpcl-dev = stdenv.mkDerivation rec {
pname = "libpcl-dev";
version = "1.12-2";
src = pkgs.fetchurl {
url = "https://launchpadlibrarian.net/521269536/libpcl1-dev_${version}_amd64.deb";
sha256 = "sha256-Z1wP0K8hfV1f9ypee9XIx6H0JOTidhtXDBe82mlRaOg=";
};
nativeBuildInputs = with pkgs; [
dpkg
autoPatchelfHook
];
unpackPhase = ''
dpkg-deb -x $src .
'';
installPhase = ''
mkdir -p $out
cp -r usr/* $out/
# Hacky bullshit
cp ${libpcl}/lib/x86_64-linux-gnu/libpcl.so.1.0.11 $out/lib/x86_64-linux-gnu/libpcl.so.1.0.11
rm $out/share/doc/libpcl1-dev/changelog.Debian.gz
'';
};
# ===========================================================================================
# Specify dependencies
# https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies-overview
# Just for a "nix develop" shell, buildInputs can be used for everything.
# ===========================================================================================
# 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
# - Setup hooks, for example makeWrapper
# - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl
nativeBuildInputs = with pkgs; [
# Languages:
bintools
gcc
# clang
aspectcxx
# C/C++:
gnumake
cmake
pkg-config
doxygen
];
# Add dependencies to buildInputs if they will end up copied or linked into the final output or otherwise used at runtime:
# - 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
buildInputs = with pkgs; [
# C/C++:
libpcl-dev
libiberty
libelf
libdwarf
boost
llvmPackages_18.llvm
mariadb-connector-c
fontconfig
zlib
capstone
protobuf
binutils
# No clue what I need from those
xorg.libX11
xorg.libXext
xorg.libXrender
xorg.libXrandr
xorg.libXinerama
xorg.libXcursor
xorg.libXi
xorg.libXfixes
];
# ===========================================================================================
# Define buildable + installable packages
# ===========================================================================================
package = stdenv.mkDerivation {
inherit nativeBuildInputs buildInputs;
pname = "fail";
version = "1.0.1";
src = ./.;
enableParallelBuilding = true;
cmakeFlags = [
# Our CMake is too new :( Try it anyway, can still downgrade later...
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5"
# AspectC++
# "-DCMAKE_AGPP_FLAGS=--c_compiler${clang}/bin/clang++"
"-DCMAKE_AGPP_FLAGS=-D__NO_MATH_INLINES"
# "-DCMAKE_AGPP_FLAGS=--c_compiler${clang}/bin/clang++ -D__NO_MATH_INLINES -D__STRICT_ANSI__"
# Tell CMake where the libs are
"-DLibIberty_INCLUDE_DIRS=${pkgs.libiberty}/include"
"-DLibIberty_LIBRARIES=${pkgs.libiberty}/lib/libiberty.a"
"-DLIBELF_INCLUDE_DIRS=${pkgs.libelf}/include"
"-DLIBELF_LIBRARIES=${pkgs.libelf}/lib/libelf.a"
"-DLIBDWARF_INCLUDE_DIRS=${pkgs.libdwarf}/include"
"-DLIBDWARF_LIBRARIES=${pkgs.libdwarf}/lib/libdwarf.a"
"-DCAPSTONE_INCLUDE_DIR=${pkgs.capstone}/include"
"-DCAPSTONE_LIBRARY=${pkgs.capstone}/lib/libcapstone.a"
"-DLIBPCL_LIBRARIES=${libpcl-dev}/lib/libpcl.a"
];
installPhase = ''
mkdir -p $out/bin
mv ./fail $out/bin/
'';
};
in rec {
# Provide package for "nix build"
defaultPackage = package;
defaultApp = flake-utils.lib.mkApp {
drv = defaultPackage;
};
# Provide environment for "nix develop"
devShell = pkgs.mkShell {
inherit nativeBuildInputs buildInputs;
name = description;
# =========================================================================================
# Define environment variables
# =========================================================================================
# Custom dynamic libraries:
# LD_LIBRARY_PATH = builtins.concatStringsSep ":" [
# # Rust Bevy GUI app:
# # "${pkgs.xorg.libX11}/lib"
# # "${pkgs.xorg.libXcursor}/lib"
# # "${pkgs.xorg.libXrandr}/lib"
# # "${pkgs.xorg.libXi}/lib"
# # "${pkgs.libGL}/lib"
#
# # JavaFX app:
# # "${pkgs.libGL}/lib"
# # "${pkgs.gtk3}/lib"
# # "${pkgs.glib.out}/lib"
# # "${pkgs.xorg.libXtst}/lib"
# ];
# Dynamic libraries from buildinputs:
LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath buildInputs;
# Set matplotlib backend
# MPLBACKEND = "TkAgg";
# =========================================================================================
# Define shell environment
# =========================================================================================
# Setup the shell when entering the "nix develop" environment (bash script).
shellHook = let
mkCmakeScript = type: let
typeLower = lib.toLower type;
in
pkgs.writers.writeFish "cmake-${typeLower}.fish" ''
cd $FLAKE_PROJECT_ROOT
echo "Removing build directory ./cmake-build-${typeLower}/"
rm -rf ./cmake-build-${typeLower}
echo "Creating build directory"
mkdir cmake-build-${typeLower}
cd cmake-build-${typeLower}
echo "Running cmake"
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="${type}" -DCMAKE_EXPORT_COMPILE_COMMANDS="On" ..
echo "Linking compile_commands.json"
cd ..
ln -sf ./cmake-build-${typeLower}/compile_commands.json ./compile_commands.json
'';
cmakeDebug = mkCmakeScript "Debug";
cmakeRelease = mkCmakeScript "Release";
mkBuildScript = type: let
typeLower = lib.toLower type;
in
pkgs.writers.writeFish "cmake-build.fish" ''
cd $FLAKE_PROJECT_ROOT/cmake-build-${typeLower}
echo "Running cmake"
cmake --build .
'';
buildDebug = mkBuildScript "Debug";
buildRelease = mkBuildScript "Release";
# Use this to specify commands that should be ran after entering fish shell
initProjectShell = pkgs.writers.writeFish "init-shell.fish" ''
echo "Entering \"${description}\" environment..."
# Determine the project root, used e.g. in cmake scripts
set -g -x FLAKE_PROJECT_ROOT (git rev-parse --show-toplevel)
# C/C++:
# abbr -a cmake-debug "${cmakeDebug}"
# abbr -a cmake-release "${cmakeRelease}"
# abbr -a build-debug "${buildDebug}"
# abbr -a build-release "${buildRelease}"
'';
in
builtins.concatStringsSep "\n" [
# Launch into pure fish shell
''
exec "$(type -p fish)" -C "source ${initProjectShell} && abbr -a menu '${pkgs.bat}/bin/bat "${initProjectShell}"'"
''
];
};
});
}

View File

@ -1,7 +1,7 @@
build-all: build-all:
docker build -t danceos/fail-base fail-base --build-arg CACHE_DATE="$(shell date)" docker build -t fail-base fail-base --build-arg CACHE_DATE="$(shell date)"
docker build -t danceos/fail-generic-tracing fail-generic-tracing docker build -t fail-generic-tracing fail-generic-tracing
docker build -t danceos/fail-demo fail-demo --build-arg CACHE_DATE="$(shell date)" docker build -t fail-demo fail-demo --build-arg CACHE_DATE="$(shell date)"
run-all: .compose ssh run-all: .compose ssh

View File

@ -13,7 +13,7 @@ services:
- fail-network - fail-network
fail-demo: fail-demo:
image: danceos/fail-demo image: fail-demo
container_name: fail-demo container_name: fail-demo
ports: ports:
- "5000:5000" # Result Browser - "5000:5000" # Result Browser

View File

@ -3,7 +3,7 @@
# generic-tracing experiment was already built and the binaries are in # generic-tracing experiment was already built and the binaries are in
# place (~fail/bin/*) # place (~fail/bin/*)
FROM danceos/fail-generic-tracing FROM fail-generic-tracing
LABEL org.opencontainers.image.authors="Christian Dietrich <stettberger@dokucode.de>" LABEL org.opencontainers.image.authors="Christian Dietrich <stettberger@dokucode.de>"

View File

@ -1,6 +1,6 @@
# Inherit from docker container that has the fail source code prepared, # Inherit from docker container that has the fail source code prepared,
# including all tools which are needed to build FAIL* # including all tools which are needed to build FAIL*
FROM danceos/fail-base FROM fail-base
LABEL org.opencontainers.image.authors="Christian Dietrich <stettberger@dokucode.de>" LABEL org.opencontainers.image.authors="Christian Dietrich <stettberger@dokucode.de>"