Skip to content

Commit

Permalink
try nix flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
pca006132 committed May 12, 2022
1 parent b43e8c2 commit c4a36d0
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/manifold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,13 @@ jobs:
cd build/test
./Release/manifold_test.exe
build_nix:
strategy:
matrix:
variant: [cpp, omp, cuda, js]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
- uses: cachix/install-nix-action@v15
- run: nix build -L '.?submodules=1#manifold-${{matrix.variant}}'

42 changes: 42 additions & 0 deletions flake.lock

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

92 changes: 92 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "nixpkgs/nixos-21.11";

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
manifold = { backend ? "CPP", doCheck ? true, build-tools ? [ ], runtime ? [ ] }: pkgs.stdenv.mkDerivation {
inherit doCheck;
pname = "manifold-${backend}";
version = "beta";
src = self;
patches = [ ./assimp.diff ];
nativeBuildInputs = (with pkgs; [ cmake python38 ]) ++ build-tools;
buildInputs = runtime;
cmakeFlags = [ "-DTHRUST_BACKEND=${backend}" ];
checkPhase = ''
cd test
./manifold_test
cd ../
'';
installPhase = ''
mkdir -p $out
cp manifold/libmanifold.a $out/
cp meshIO/libmeshIO.a $out/
cp tools/loadMesh $out
cp tools/perfTest $out
'';
};
devShell = { additional ? [ ] }: pkgs.mkShell {
buildInputs = with pkgs; [
cmake
ccls
llvmPackages.openmp
clang-tools
clang_13
emscripten
] ++ additional;
};
in
{
packages.manifold-cpp = manifold { };
packages.manifold-omp = manifold { backend = "OMP"; runtime = [ pkgs.llvmPackages.openmp ]; };
packages.manifold-cuda = manifold {
backend = "CUDA";
runtime = [
pkgs.cudaPackages.cudatoolkit_11
];
doCheck = false;
};
packages.manifold-js = pkgs.buildEmscriptenPackage {
name = "manifold-js";
version = "beta";
src = self;
patches = [ ./assimp.diff ];
nativeBuildInputs = (with pkgs; [ cmake python38 ]);
buildInputs = [ pkgs.nodejs ];
configurePhase = ''
mkdir build
cd build
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
'';
enableParallelBuilding = true;
buildPhase = ''
emmake make -j"$buildCores"
'';
checkPhase = ''
cd test
node manifold_test.js
cd ../
'';
installPhase = ''
mkdir -p $out
cd tools
cp *.js $out/
cp *.wasm $out/
'';
};
devShell = devShell { };
devShells.cuda = devShell {
additional = [
pkgs.cudaPackages.cudatoolkit_11
];
};
}
);
}

0 comments on commit c4a36d0

Please sign in to comment.