From 036eb6786042a46fb9b07a37b139e25d9b6721c0 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 8 Jul 2024 19:18:29 +0200 Subject: [PATCH] Add shell.nix with an environment for building and using Clad on NixOS I use this nix environment to build Clad standalone and test the reproducers. Until recently, I could just use my native Arch Linux environment to do so, but after Arch dropped LLVM 17 this was not possible anymore (Clad doesn't work the LLVM 18 yet). Therefore, I had to find another solution, and nix packages works quite well. It would be nice to have this in the repo so also other people can work with Clad in NixOS, without having to waste time figuring out the dependencies and necessary CMake flags. --- shell.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..e50899002 --- /dev/null +++ b/shell.nix @@ -0,0 +1,30 @@ +# Declaration of an environment that can be used to build Clad and compile +# binaries with clang++ using the Clad plugin. +# +# Provided environment variables: +# - CMAKE_FLAGS : flags for configuring with CMake + +{ + pkgs ? import { }, +}: + +pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + llvmPackages_16.clang-unwrapped # for Clang library + llvmPackages_16.clangUseLLVM # for clang wrapper (useful to compile code that tests Cland) + llvmPackages_16.libcxxStdenv # standard C++ library for Clang + llvmPackages_16.stdenv # standard C library for Clang + llvm_16 # using LLVM 16, because this is also what ROOT uses + ]; + + shellHook = + with { + cmakeFlags = [ + "-DCLAD_DISABLE_TESTS=ON" + "-DLLVM_DIR=${pkgs.llvm_16.dev}" + "-DClang_DIR=${pkgs.llvmPackages_16.clang-unwrapped.dev}" + ]; + }; '' + CMAKE_FLAGS="${pkgs.lib.strings.concatStrings (pkgs.lib.strings.intersperse " " cmakeFlags)}" + ''; +}