Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Nix build files #497

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{ pkgs ? import <nixpkgs> {}
, 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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default cling package is meant for use by end-users directly, so it only provides the /bin/cling script which feeds arguments to the unwrapped version. See my comment on cxxFlags below for why it needs to be wrapped.

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"
];
Comment on lines +32 to +48
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The funny thing about Nix is that it's optimized for prebuilt packages, meaning it stores dev outputs (headers, etc...) in a different path than default outputs (executables). This breaks the assumption that they exist at the same prefix, so we force xcpp to run with those flags set to our development paths.


fixupPhase = ''
wrapProgram $out/bin/xcpp --add-flags "$flags"
'';
}
26 changes: 26 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions flake.nix
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nix flakes are basically Nix packages which specify their inputs. The flake.lock file locks those inputs to a specific commit, allowing for reproducible builds.

Original file line number Diff line number Diff line change
@@ -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 {};
};
}