From b4dd4a3f4db26d5ade5bdec4054c1444e3d98898 Mon Sep 17 00:00:00 2001 From: LordGrimmauld Date: Thu, 23 Nov 2023 12:03:02 +0100 Subject: [PATCH] added dev and debug shells --- debug/default.nix | 19 +++++++++++++++++++ development/default.nix | 28 ++++++++++++++++++++++++++++ development/nix-cmake | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 debug/default.nix create mode 100644 development/default.nix create mode 100755 development/nix-cmake diff --git a/debug/default.nix b/debug/default.nix new file mode 100644 index 0000000..0a434d5 --- /dev/null +++ b/debug/default.nix @@ -0,0 +1,19 @@ +with import { }; + +stdenv.mkDerivation rec { + name = "debug"; + + nativeBuildInputs = with pkgs; [ + hyfetch + qdirstat + vdpauinfo + libva-utils + glxinfo + acpi + lm_sensors + lshw + pciutils + usbutils + powertop + ]; +} diff --git a/development/default.nix b/development/default.nix new file mode 100644 index 0000000..bfafa74 --- /dev/null +++ b/development/default.nix @@ -0,0 +1,28 @@ +with import { }; + +gcc11Stdenv.mkDerivation rec { +#gccStdenv.mkDerivation rec { +#clang16Stdenv.mkDerivation rec { + name = "devel"; + + nativeBuildInputs = with pkgs; [ + git + ninja + git-lfs + jdk19 + jetbrains.clion + jetbrains.pycharm-community + jetbrains.idea-community + scala_3 + moreutils + hotspot + cmakeWithGui + gnumake + ccache + cudatoolkit_11 + git + python3 + linuxPackages.perf + ] ; + shellHook = ''export CXXFLAGS="-march=native -O3"''; +} diff --git a/development/nix-cmake b/development/nix-cmake new file mode 100755 index 0000000..b575373 --- /dev/null +++ b/development/nix-cmake @@ -0,0 +1,32 @@ +#! /usr/bin/env cached-nix-shell +#! nix-shell -p python3 -i python3 + +# let's say you have a C++ project in Nix that you want to work on with CLion so that the Nix dependencies are available +# put this script in your project directory +# then, in Settings -> Build, Execution, Deployment -> Toolchains set CMake to this script +# if you need any extra nix-shell arguments, add them to the invocation at the bottom + +# Adapted script from https://gist.github.com/chpatrick/61a5d486dd0d806bdf07e1b1ddc85ce5 + +import os +import sys +import shlex + +scriptDir = os.path.dirname(os.path.realpath(__file__)) + +args = list(map(shlex.quote, sys.argv[1:])) + +# Use the cmakeFlags set by Nix - this doesn't work with --build +if "--build" not in args: + args.insert(0, "$cmakeFlags") + args.append("--no-warn-unused-cli") + +cwd = shlex.quote(os.getcwd()) +cmd = 'cd ' + cwd + ' && cmake ' + ' '.join(args) + +os.chdir(scriptDir) +os.execvp("cached-nix-shell", [ + 'nix-shell', + '--pure', + '--run', cmd + ])