diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..1ef8a22a59 --- /dev/null +++ b/default.nix @@ -0,0 +1,4 @@ +(import (fetchTarball + "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { + src = builtins.fetchGit ./.; + }).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..8436f4cdfe --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1640718479, + "narHash": "sha256-hm5yC3ynZE9bH564NmFdWv07RtCKr/fgT8Veh594j4M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d53978239b265066804a45b7607b010b9cb4c50c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d53978239b265066804a45b7607b010b9cb4c50c", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..007d3c18d3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,14 @@ +{ + description = "openvdb"; + inputs = { + # pick latest commit from stable branch and test it so no suprises + nixpkgs.url = "github:NixOS/nixpkgs/d53978239b265066804a45b7607b010b9cb4c50c"; + }; + + outputs = inputs: { + + defaultPackage.x86_64-linux = import ./openvdb.nix { + nixpkgs = inputs.nixpkgs; + }; + }; +} diff --git a/openvdb.nix b/openvdb.nix new file mode 100644 index 0000000000..e51028cebb --- /dev/null +++ b/openvdb.nix @@ -0,0 +1,42 @@ +{ nixpkgs, ... }: +let + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ (import ./overlay.nix) ]; + }; +in + with pkgs; + stdenv.mkDerivation { + name = "openvdb"; + version = "9.0.0"; + + # https://nixos.org/nix/manual/#builtin-filterSource + src = builtins.filterSource + (path: type: lib.cleanSourceFilter path type + && baseNameOf path != "doc/*" + && baseNameOf path != "openvdb_houdini/*" + && baseNameOf path != "openvdb_maya/*" + && baseNameOf path != "pendingchanges/*" + && baseNameOf path != "tsc/*") ./.; + + cmakeFlags =["-DOPENVDB_BUILD_VDB_VIEW=ON"]; + + # easily maxes out RAM on github actions or systems <64 GB + enableParallelBuilding = true; + nativeBuildInputs = [ cmake pkg-config ]; + + # required dependencies for downstream development + propagatedBuildInputs = [ + openexr + tbb + c-blosc + boost175 + ]; + + buildInputs = [ + unzip jemalloc ilmbase + # for the optional VDB_VIEW binary opengl related dependencies: + libGL glfw3 x11 libGLU xorg.libXdmcp + ]; + + } diff --git a/overlay.nix b/overlay.nix new file mode 100644 index 0000000000..be6a9bea9d --- /dev/null +++ b/overlay.nix @@ -0,0 +1,39 @@ +final: prev: { + tbb = prev.stdenv.mkDerivation { + name="tbb"; + version = "2021.4"; + + src = prev.fetchFromGitHub { + owner = "oneapi-src"; + repo = "oneTBB"; + rev = "v2021.4.0"; + sha256 = "eJ/NQ1XkWWlioBu05zbtZ/EwVxCAQzz5pkkKgN4RB0Y="; + }; + + nativeBuildInputs = [ prev.pkgs.cmake prev.pkgs.pkg-config ]; + + makeFlags = prev.lib.optionals prev.stdenv.cc.isClang [ + "compiler=clang" + ]; + + cmakeFlags =["-DTBB_TEST=OFF"]; + + enableParallelBuilding = true; + + meta = with prev.lib; { + description = "Intel Thread Building Blocks C++ Library"; + homepage = "http://threadingbuildingblocks.org/"; + license = licenses.asl20; + longDescription = '' + Intel Threading Building Blocks offers a rich and complete approach to + expressing parallelism in a C++ program. It is a library that helps you + take advantage of multi-core processor performance without having to be a + threading expert. Intel TBB is not just a threads-replacement library. It + represents a higher-level, task-based parallelism that abstracts platform + details and threading mechanisms for scalability and performance. + ''; + platforms = platforms.unix; + maintainers = with maintainers; [ thoughtpolice dizfer ]; + }; + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000..9a25fabdb8 --- /dev/null +++ b/shell.nix @@ -0,0 +1,4 @@ +(import (fetchTarball + "https://github.com/edolstra/flake-compat/archive/master.tar.gz") { + src = builtins.fetchGit ./.; + }).shellNix