nixos: add wip FAIL* package derivation to flake.nix
This commit is contained in:
315
flake.nix
315
flake.nix
@ -1,32 +1,22 @@
|
||||
rec {
|
||||
description = "";
|
||||
description = "FAIL* - Fault Injection Leveraged";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs"; # Use nixpkgs from system registry
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
clj-nix.url = "github:jlesquembre/clj-nix";
|
||||
clj-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
rust-overlay,
|
||||
clj-nix,
|
||||
}:
|
||||
# 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 = [
|
||||
rust-overlay.overlays.default
|
||||
];
|
||||
overlays = [];
|
||||
};
|
||||
inherit (pkgs) lib stdenv;
|
||||
|
||||
@ -34,57 +24,28 @@ rec {
|
||||
# Define custom dependencies
|
||||
# ===========================================================================================
|
||||
|
||||
# Python package example
|
||||
# typed-ffmpeg = pkgs.python313Packages.buildPythonPackage rec {
|
||||
# pname = "typed_ffmpeg";
|
||||
# version = "3.6";
|
||||
#
|
||||
# src = pkgs.python313Packages.fetchPypi {
|
||||
# inherit pname version;
|
||||
# hash = "sha256-YPspq/lqI/jx/9FCQntmQPw4lrPIsdxtHTUg0F0QbrM=";
|
||||
# };
|
||||
#
|
||||
# pyproject = true;
|
||||
# build-system = [
|
||||
# pkgs.python313Packages.setuptools
|
||||
# pkgs.python313Packages.setuptools-scm
|
||||
# ];
|
||||
# };
|
||||
|
||||
# python = pkgs.python313.withPackages (p:
|
||||
# with p; [
|
||||
# # numpy
|
||||
# # matplotlib
|
||||
# # typed-ffmpeg
|
||||
# # pyside6
|
||||
# ]);
|
||||
|
||||
# rust = pkgs.rust-bin.stable.latest.default.override {
|
||||
# extensions = ["rust-src"]; # Include the Rust stdlib source (for IntelliJ)
|
||||
# };
|
||||
|
||||
# 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 = pkgs.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;
|
||||
# };
|
||||
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 = pkgs.hiPrio (pkgs.wrapCCWith {
|
||||
# gcc_multilib = lib.hiPrio (pkgs.wrapCCWith {
|
||||
# cc = pkgs.gcc.cc; # Unwrapped gcc
|
||||
# libc = pkgs.glibc_multi;
|
||||
# bintools = bintools_multilib;
|
||||
@ -95,6 +56,84 @@ rec {
|
||||
# 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
|
||||
@ -107,37 +146,16 @@ rec {
|
||||
# - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl
|
||||
nativeBuildInputs = with pkgs; [
|
||||
# Languages:
|
||||
# python
|
||||
# rust
|
||||
# bintools
|
||||
# gcc
|
||||
bintools
|
||||
gcc
|
||||
# clang
|
||||
# bintools_multilib
|
||||
# gcc_multilib
|
||||
# clang_multilib
|
||||
# clojure
|
||||
# jdk
|
||||
aspectcxx
|
||||
|
||||
# C/C++:
|
||||
# gdb
|
||||
# valgrind
|
||||
gnumake
|
||||
# cmake
|
||||
# pkg-config
|
||||
|
||||
# Clojure:
|
||||
# leiningen
|
||||
# clj-nix.packages.${system}.deps-lock
|
||||
|
||||
# Java:
|
||||
# gradle
|
||||
|
||||
# Python:
|
||||
# hatch
|
||||
# py-spy
|
||||
|
||||
# Qt:
|
||||
# qt6.wrapQtAppsHook # For the shellHook
|
||||
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:
|
||||
@ -145,50 +163,77 @@ rec {
|
||||
# - Interpreters needed by patchShebangs for scripts which are installed, which can be the case for e.g. perl
|
||||
buildInputs = with pkgs; [
|
||||
# C/C++:
|
||||
# boost
|
||||
# sfml
|
||||
libpcl-dev
|
||||
libiberty
|
||||
libelf
|
||||
libdwarf
|
||||
boost
|
||||
|
||||
# Qt:
|
||||
# qt6.qtbase
|
||||
# qt6.full
|
||||
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 = "";
|
||||
# version = "1.0.0";
|
||||
# src = ./.;
|
||||
#
|
||||
# installPhase = ''
|
||||
# mkdir -p $out/bin
|
||||
# mv ./BINARY $out/bin
|
||||
# '';
|
||||
# };
|
||||
# package = clj-nix.lib.mkCljApp {
|
||||
# inherit pkgs;
|
||||
# modules = [
|
||||
# # Option list: https://jlesquembre.github.io/clj-nix/options/
|
||||
# {
|
||||
# name = "";
|
||||
# version = "1.0.0";
|
||||
# main-ns = "";
|
||||
# projectSrc = ./.;
|
||||
# withLeiningen = true;
|
||||
# buildCommand = "lein uberjar"; # Requires "withLeiningen = true;"
|
||||
# jdk = pkgs.jdk; # Default is pkgs.jdk_headless
|
||||
# # customJdk.enable = true;
|
||||
# # nativeImage.enable = true;
|
||||
# }
|
||||
# ];
|
||||
# };
|
||||
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;
|
||||
# };
|
||||
defaultPackage = package;
|
||||
defaultApp = flake-utils.lib.mkApp {
|
||||
drv = defaultPackage;
|
||||
};
|
||||
|
||||
# Provide environment for "nix develop"
|
||||
devShell = pkgs.mkShell {
|
||||
@ -199,9 +244,6 @@ rec {
|
||||
# Define environment variables
|
||||
# =========================================================================================
|
||||
|
||||
# Rust stdlib source:
|
||||
# RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
|
||||
|
||||
# Custom dynamic libraries:
|
||||
# LD_LIBRARY_PATH = builtins.concatStringsSep ":" [
|
||||
# # Rust Bevy GUI app:
|
||||
@ -219,13 +261,7 @@ rec {
|
||||
# ];
|
||||
|
||||
# Dynamic libraries from buildinputs:
|
||||
# LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath buildInputs;
|
||||
|
||||
# QT imports to use with "qmlls -E"
|
||||
# QML_IMPORT_PATH = "${pkgs.qt6.full}/lib/qt-6/qml";
|
||||
|
||||
# Set PYTHONPATH
|
||||
# PYTHONPATH = ".";
|
||||
LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath buildInputs;
|
||||
|
||||
# Set matplotlib backend
|
||||
# MPLBACKEND = "TkAgg";
|
||||
@ -280,22 +316,11 @@ rec {
|
||||
# Determine the project root, used e.g. in cmake scripts
|
||||
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++:
|
||||
# abbr -a cmake-debug "${cmakeDebug}"
|
||||
# abbr -a cmake-release "${cmakeRelease}"
|
||||
# abbr -a build-debug "${buildDebug}"
|
||||
# abbr -a build-release "${buildRelease}"
|
||||
|
||||
# Clojure:
|
||||
# abbr -a clojure-deps "deps-lock --lein"
|
||||
|
||||
# Python:
|
||||
# abbr -a run "python ./app/main.py"
|
||||
# abbr -a profile "py-spy record -o profile.svg -- python ./app/main.py && firefox profile.svg"
|
||||
# abbr -a ptop "py-spy top -- python ./app/main.py"
|
||||
'';
|
||||
in
|
||||
builtins.concatStringsSep "\n" [
|
||||
@ -303,14 +328,6 @@ rec {
|
||||
''
|
||||
exec "$(type -p fish)" -C "source ${initProjectShell} && abbr -a menu '${pkgs.bat}/bin/bat "${initProjectShell}"'"
|
||||
''
|
||||
|
||||
# Qt: Launch into wrapped fish shell
|
||||
# https://nixos.org/manual/nixpkgs/stable/#sec-language-qt
|
||||
# ''
|
||||
# fishdir=$(mktemp -d)
|
||||
# makeWrapper "$(type -p fish)" "$fishdir/fish" "''${qtWrapperArgs[@]}"
|
||||
# exec "$fishdir/fish" -C "source ${initProjectShell} && abbr -a menu '${pkgs.bat}/bin/bat "${initProjectShell}"'"
|
||||
# ''
|
||||
];
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user