update flake
This commit is contained in:
6
flake.lock
generated
6
flake.lock
generated
@ -20,11 +20,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770843696,
|
"lastModified": 1772479524,
|
||||||
"narHash": "sha256-LovWTGDwXhkfCOmbgLVA10bvsi/P8eDDpRudgk68HA8=",
|
"narHash": "sha256-u7nCaNiMjqvKpE+uZz9hE7pgXXTmm5yvdtFaqzSzUQI=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "2343bbb58f99267223bc2aac4fc9ea301a155a16",
|
"rev": "4215e62dc2cd3bc705b0a423b9719ff6be378a43",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
310
flake.nix
310
flake.nix
@ -14,22 +14,122 @@ rec {
|
|||||||
# Create a shell (and possibly package) for each possible system, not only x86_64-linux
|
# Create a shell (and possibly package) for each possible system, not only x86_64-linux
|
||||||
flake-utils.lib.eachDefaultSystem (
|
flake-utils.lib.eachDefaultSystem (
|
||||||
system: let
|
system: let
|
||||||
|
# =========================================================================================
|
||||||
|
# Define pkgs/stdenvs
|
||||||
|
# =========================================================================================
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
overlays = [];
|
overlays = [];
|
||||||
};
|
};
|
||||||
inherit (pkgs) lib stdenv;
|
|
||||||
|
clangPkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
config.allowUnfree = true;
|
||||||
|
overlays = [];
|
||||||
|
|
||||||
|
# Use this to change the compiler:
|
||||||
|
# - GCC: pkgs.stdenv
|
||||||
|
# - Clang: pkgs.clangStdenv
|
||||||
|
# NixOS packages are built using GCC by default. Using clang requires a full rebuild/redownload.
|
||||||
|
config.replaceStdenv = {pkgs}: pkgs.clangStdenv;
|
||||||
|
};
|
||||||
|
|
||||||
windowsPkgs = import nixpkgs {
|
windowsPkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
config.allowUnfree = true;
|
||||||
|
overlays = [];
|
||||||
|
|
||||||
|
# Use this to cross compile to a different system
|
||||||
crossSystem = {
|
crossSystem = {
|
||||||
config = "x86_64-w64-mingw32";
|
config = "x86_64-w64-mingw32";
|
||||||
};
|
};
|
||||||
config.allowUnfree = true;
|
|
||||||
overlays = [];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inherit (pkgs) lib stdenv;
|
||||||
|
|
||||||
|
# =========================================================================================
|
||||||
|
# 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 "Ninja" \
|
||||||
|
-DCMAKE_BUILD_TYPE="${type}" \
|
||||||
|
..
|
||||||
|
|
||||||
|
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"
|
||||||
|
NIX_ENFORCE_NO_NATIVE=0 cmake --build . -j$(nproc)
|
||||||
|
'';
|
||||||
|
|
||||||
|
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}"
|
||||||
|
abbr -a debug "${buildDebug} && ./cmake-build-debug/masssprings"
|
||||||
|
abbr -a release "${buildRelease} && ./cmake-build-release/masssprings"
|
||||||
|
abbr -a debug-clean "${cmakeDebug} && ${buildDebug} && ./cmake-build-debug/masssprings"
|
||||||
|
abbr -a release-clean "${cmakeRelease} && ${buildRelease} && ./cmake-build-release/masssprings"
|
||||||
|
|
||||||
|
abbr -a rungdb "${buildDebug} && gdb --tui ./cmake-build-debug/masssprings"
|
||||||
|
abbr -a runperf "${buildRelease} && perf record -g ./cmake-build-release/masssprings && hotspot ./perf.data"
|
||||||
|
abbr -a runtracy "tracy -a 127.0.0.1 &; ${buildRelease} && sudo -E ./cmake-build-release/masssprings"
|
||||||
|
abbr -a runvalgrind "${buildDebug} && valgrind --leak-check=full --show-reachable=no --show-leak-kinds=definite,indirect,possible --track-origins=no --suppressions=valgrind.supp --log-file=valgrind.log ./cmake-build-debug/masssprings && cat valgrind.log"
|
||||||
|
abbr -a runtests "${buildDebug} && ./cmake-build-debug/tests"
|
||||||
|
abbr -a runbenchs "${buildRelease} && sudo cpupower frequency-set --governor performance && ./cmake-build-release/benchmarks; sudo cpupower frequency-set --governor powersave"
|
||||||
|
|
||||||
|
abbr -a clusters-rh "${buildRelease} && ./cmake-build-release/masssprings --output=clusters.puzzle --space=rh --w=6 --h=6 --gx=4 --gy=2 --blocks=4"
|
||||||
|
abbr -a clusters "${buildRelease} && ./cmake-build-release/masssprings clusters.puzzle"
|
||||||
|
|
||||||
|
abbr -a runclion "clion ./CMakeLists.txt 2>/dev/null 1>&2 & disown;"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
builtins.concatStringsSep "\n" [
|
||||||
|
# Launch into pure fish shell
|
||||||
|
''
|
||||||
|
exec "$(type -p fish)" -C "source ${initProjectShell}"
|
||||||
|
''
|
||||||
|
];
|
||||||
|
|
||||||
# ===========================================================================================
|
# ===========================================================================================
|
||||||
# Define custom dependencies
|
# Define custom dependencies
|
||||||
# ===========================================================================================
|
# ===========================================================================================
|
||||||
@ -99,29 +199,20 @@ rec {
|
|||||||
# - 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
|
||||||
# - 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
|
||||||
|
# NOTE: Do not add compiler here, they are provided by the stdenv
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
# Languages:
|
# Languages:
|
||||||
binutils
|
# binutils
|
||||||
gcc
|
|
||||||
|
|
||||||
# C/C++:
|
# C/C++:
|
||||||
gdb
|
|
||||||
valgrind
|
|
||||||
# gnumake
|
|
||||||
cmake
|
cmake
|
||||||
ninja
|
ninja
|
||||||
# cling
|
gdb
|
||||||
# pkg-config
|
valgrind
|
||||||
# clang-tools
|
kdePackages.kcachegrind
|
||||||
# compdb
|
|
||||||
# pprof
|
|
||||||
# gprof2dot
|
|
||||||
perf
|
perf
|
||||||
hotspot
|
hotspot
|
||||||
kdePackages.kcachegrind
|
# heaptrack
|
||||||
gdbgui
|
|
||||||
massif-visualizer
|
|
||||||
heaptrack
|
|
||||||
# renderdoc
|
# renderdoc
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -135,15 +226,18 @@ rec {
|
|||||||
thread-pool
|
thread-pool
|
||||||
boost
|
boost
|
||||||
|
|
||||||
# Debugging
|
# Debugging/Testing/Profiling
|
||||||
tracy-wayland
|
tracy-wayland
|
||||||
backward-cpp
|
backward-cpp
|
||||||
libbfd
|
libbfd
|
||||||
catch2_3
|
catch2_3
|
||||||
|
gbenchmark
|
||||||
];
|
];
|
||||||
|
|
||||||
# ===========================================================================================
|
# ===========================================================================================
|
||||||
# Define buildable + installable packages
|
# Define buildable + installable packages
|
||||||
# ===========================================================================================
|
# ===========================================================================================
|
||||||
|
|
||||||
package = stdenv.mkDerivation rec {
|
package = stdenv.mkDerivation rec {
|
||||||
inherit buildInputs;
|
inherit buildInputs;
|
||||||
pname = "masssprings";
|
pname = "masssprings";
|
||||||
@ -159,6 +253,7 @@ rec {
|
|||||||
"-DDISABLE_TRACY=On"
|
"-DDISABLE_TRACY=On"
|
||||||
"-DDISABLE_BACKWARD=On"
|
"-DDISABLE_BACKWARD=On"
|
||||||
"-DDISABLE_TESTS=On"
|
"-DDISABLE_TESTS=On"
|
||||||
|
"-DDISABLE_BENCH=On"
|
||||||
];
|
];
|
||||||
|
|
||||||
hardeningDisable = ["all"];
|
hardeningDisable = ["all"];
|
||||||
@ -206,6 +301,8 @@ rec {
|
|||||||
"-DCMAKE_SYSTEM_NAME=Windows"
|
"-DCMAKE_SYSTEM_NAME=Windows"
|
||||||
"-DDISABLE_TRACY=On"
|
"-DDISABLE_TRACY=On"
|
||||||
"-DDISABLE_BACKWARD=On"
|
"-DDISABLE_BACKWARD=On"
|
||||||
|
"-DDISABLE_TESTS=On"
|
||||||
|
"-DDISABLE_BENCH=On"
|
||||||
];
|
];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
@ -227,156 +324,53 @@ rec {
|
|||||||
# Provide environment for "nix develop"
|
# Provide environment for "nix develop"
|
||||||
devShells = {
|
devShells = {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
inherit nativeBuildInputs buildInputs;
|
inherit nativeBuildInputs buildInputs shellHook;
|
||||||
name = description;
|
name = description;
|
||||||
|
|
||||||
# =========================================================================================
|
# =========================================================================================
|
||||||
# Define environment variables
|
# 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:
|
# Dynamic libraries from buildinputs:
|
||||||
LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath buildInputs;
|
LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath buildInputs;
|
||||||
|
|
||||||
# =========================================================================================
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# set -g -x CC ${pkgs.clang}/bin/clang
|
|
||||||
# set -g -x CXX ${pkgs.clang}/bin/clang++
|
|
||||||
|
|
||||||
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 "Ninja" \
|
|
||||||
-DCMAKE_BUILD_TYPE="${type}" \
|
|
||||||
..
|
|
||||||
|
|
||||||
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"
|
|
||||||
NIX_ENFORCE_NO_NATIVE=0 cmake --build . -j$(nproc)
|
|
||||||
'';
|
|
||||||
|
|
||||||
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}"
|
|
||||||
abbr -a debug "${buildDebug} && ./cmake-build-debug/masssprings"
|
|
||||||
abbr -a release "${buildRelease} && ./cmake-build-release/masssprings"
|
|
||||||
abbr -a debug-clean "${cmakeDebug} && ${buildDebug} && ./cmake-build-debug/masssprings"
|
|
||||||
abbr -a release-clean "${cmakeRelease} && ${buildRelease} && ./cmake-build-release/masssprings"
|
|
||||||
|
|
||||||
abbr -a rungdb "${buildDebug} && gdb --tui ./cmake-build-debug/masssprings"
|
|
||||||
abbr -a runperf "${buildRelease} && perf record -g ./cmake-build-release/masssprings && hotspot ./perf.data"
|
|
||||||
abbr -a runtracy "tracy -a 127.0.0.1 &; ${buildRelease} && sudo -E ./cmake-build-release/masssprings"
|
|
||||||
abbr -a runvalgrind "${buildDebug} && valgrind --leak-check=full --show-reachable=no --show-leak-kinds=definite,indirect,possible --track-origins=no --suppressions=valgrind.supp --log-file=valgrind.log ./cmake-build-debug/masssprings && cat valgrind.log"
|
|
||||||
abbr -a runtests "${buildDebug} && ./cmake-build-debug/tests"
|
|
||||||
|
|
||||||
abbr -a runclion "clion ./CMakeLists.txt 2>/dev/null 1>&2 & disown;"
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
builtins.concatStringsSep "\n" [
|
|
||||||
# Launch into pure fish shell
|
|
||||||
''
|
|
||||||
exec "$(type -p fish)" -C "source ${initProjectShell} && abbr -a menu '${pkgs.bat}/bin/bat "${initProjectShell}"'"
|
|
||||||
''
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO: Can't get renderdoc in FHS to work
|
# Provide environment with clang stdenv for "nix develop .#clang"
|
||||||
|
# TODO: Broken. Clang can't find stdlib headers or library headers (raylib, backward, ...).
|
||||||
|
# Does the clangStdenv not automatically collect the include paths?
|
||||||
|
clang =
|
||||||
|
pkgs.mkShell.override {
|
||||||
|
stdenv = pkgs.clangStdenv;
|
||||||
|
} {
|
||||||
|
inherit shellHook;
|
||||||
|
name = description;
|
||||||
|
|
||||||
# FHS environment for renderdoc. Access with "nix develop .#renderdoc".
|
nativeBuildInputs = with pkgs; [
|
||||||
# https://ryantm.github.io/nixpkgs/builders/special/fhs-environments
|
cmake
|
||||||
# renderdoc =
|
ninja
|
||||||
# (pkgs.buildFHSEnv {
|
];
|
||||||
# name = "renderdoc-env";
|
|
||||||
#
|
buildInputs = with pkgs; [
|
||||||
# targetPkgs = pkgs:
|
# C/C++:
|
||||||
# with pkgs; [
|
raylib
|
||||||
# # RenderDoc
|
raygui
|
||||||
# renderdoc
|
thread-pool
|
||||||
#
|
boost
|
||||||
# # Build tools
|
|
||||||
# gcc
|
# Debugging/Testing/Profiling
|
||||||
# cmake
|
backward-cpp
|
||||||
#
|
libbfd
|
||||||
# # Raylib
|
catch2_3
|
||||||
# raylib
|
gbenchmark
|
||||||
# libGL
|
];
|
||||||
# mesa
|
|
||||||
#
|
# =========================================================================================
|
||||||
# # X11
|
# Define environment variables
|
||||||
# libx11
|
# =========================================================================================
|
||||||
# libxcursor
|
|
||||||
# libxrandr
|
# Dynamic libraries from buildinputs:
|
||||||
# libxinerama
|
LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath buildInputs;
|
||||||
# libxi
|
};
|
||||||
# libxext
|
|
||||||
# libxfixes
|
|
||||||
#
|
|
||||||
# # Wayland
|
|
||||||
# wayland
|
|
||||||
# wayland-protocols
|
|
||||||
# libxkbcommon
|
|
||||||
# ];
|
|
||||||
#
|
|
||||||
# runScript = "fish";
|
|
||||||
#
|
|
||||||
# profile = ''
|
|
||||||
# '';
|
|
||||||
# }).env;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user