From dd515685668387725a116b587a46c9e4b73adfd9 Mon Sep 17 00:00:00 2001 From: TheSola10 Date: Mon, 25 Sep 2023 11:12:55 +0200 Subject: [PATCH] Added Nix build files --- default.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 26 ++++++++++++++++++++++++++ flake.nix | 9 +++++++++ 3 files changed, 88 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..7837d24 --- /dev/null +++ b/default.nix @@ -0,0 +1,53 @@ +{ pkgs ? import {} +, useLLVMLibcxx ? false +, ... }: + +with pkgs; + +pkgs.llvmPackages.stdenv.mkDerivation rec { + name = "xeus-cling"; + src = ./.; + + nativeBuildInputs = with pkgs; [ + cmake + makeWrapper + ]; + + buildInputs = with pkgs; [ + xeus + xeus-zmq + cppzmq + cling.unwrapped + argparse + xtl + pugixml + nlohmann_json + openssl + llvmPackages_9.libllvm + llvmPackages_9.libclang + libuuid + ]; + + # Runtime flags for the C++ standard library + cxxFlags = if useLLVMLibcxx then [ + "-I" "${lib.getDev llvmPackages_9.libcxx}/include/c++/v1" + "-L" "${llvmPackages_9.libcxx}/lib" + "-l" "${llvmPackages_9.libcxx}/lib/libc++.so" + ] else [ + "-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}" + "-I" "${gcc-unwrapped}/include/c++/${gcc-unwrapped.version}/x86_64-unknown-linux-gnu" + ]; + + flags = [ + "-nostdinc" + "-nostdinc++" + "-isystem" "${cling.unwrapped}/lib/clang/9.0.1/include" + ] ++ cxxFlags ++ [ + "-isystem" "${lib.getDev stdenv.cc.libc}/include" + "-isystem" "${cling.unwrapped}/include" + ]; + + fixupPhase = '' + wrapProgram $out/bin/xcpp --add-flags "$flags" + ''; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..55785eb --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1695628505, + "narHash": "sha256-gkn36kbqNQgKEs7RM7MSVQh84VIwmM9fvFCffC70mq8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "29351a88df4201a8423fb4ab72b9438251e6744e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..786db2f --- /dev/null +++ b/flake.nix @@ -0,0 +1,9 @@ +{ description = "xeus-cling Jupyter kernel"; + + inputs."nixpkgs".url = github:NixOS/nixpkgs; + + outputs = { self, nixpkgs, ... }: + { packages.x86_64-linux.default = + (import nixpkgs { system="x86_64-linux"; }).callPackage ./default.nix {}; + }; +}