Skip to content

Commit

Permalink
Add shell.nix with an environment for building and using Clad on NixOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guitargeek authored and vgvassilev committed Jul 8, 2024
1 parent 354d7ad commit 036eb67
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -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 <nixpkgs> { },
}:

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)}"
'';
}

0 comments on commit 036eb67

Please sign in to comment.