nixpkgs/pkgs/development/libraries/tachyon/default.nix

82 lines
3.0 KiB
Nix
Raw Normal View History

{ lib, stdenv
, fetchurl
, Carbon ? null
, libjpeg ? null
, libpng ? null
, withJpegSupport ? true # support jpeg output
, withPngSupport ? true # support png output
}:
assert withJpegSupport -> libjpeg != null;
assert withPngSupport -> libpng != null;
assert stdenv.isDarwin -> Carbon != null;
2016-10-10 16:43:16 +00:00
stdenv.mkDerivation rec {
pname = "tachyon";
2022-03-11 02:29:02 +00:00
version = "0.99.3";
2016-10-10 16:43:16 +00:00
src = fetchurl {
url = "http://jedi.ks.uiuc.edu/~johns/tachyon/files/${version}/${pname}-${version}.tar.gz";
2022-03-11 02:29:02 +00:00
sha256 = "sha256-rsxxm1NK2IPRl/5O2Ng2sC1VH84Zj1uJ6mN+HZHyN+E=";
2016-10-10 16:43:16 +00:00
};
buildInputs = lib.optionals stdenv.isDarwin [
Carbon
] ++ lib.optionals withJpegSupport [
libjpeg
] ++ lib.optionals withPngSupport [
libpng
];
preBuild = ''
cd unix
'' + lib.optionalString withJpegSupport ''
export USEJPEG=" -DUSEJPEG"
export JPEGLIB=" -ljpeg"
'' + lib.optionalString withPngSupport ''
export USEPNG=" -DUSEPNG"
export PNGLIB=" -lpng -lz"
'';
arch = if stdenv.hostPlatform.system == "x86_64-linux" then "linux-64-thr" else
if stdenv.hostPlatform.system == "i686-linux" then "linux-thr" else
# 2021-03-29: multithread (-DTHR -D_REENTRANT) was disabled on linux-arm
# because it caused Sage's 3D plotting tests to hang indefinitely.
# see https://github.com/NixOS/nixpkgs/pull/117465
if stdenv.hostPlatform.system == "aarch64-linux" then "linux-arm" else
if stdenv.hostPlatform.system == "armv7l-linux" then "linux-arm" else
if stdenv.hostPlatform.system == "x86_64-darwin" then "macosx-thr" else
if stdenv.hostPlatform.system == "i686-darwin" then "macosx-64-thr" else
if stdenv.hostPlatform.system == "i686-cygwin" then "win32" else
if stdenv.hostPlatform.system == "x86_64-freebsd" then "bsd" else
if stdenv.hostPlatform.system == "x686-freebsd" then "bsd" else
2016-10-10 16:43:16 +00:00
throw "Don't know what arch to select for tachyon build";
2019-10-29 22:21:22 +00:00
makeFlags = [ arch ];
2021-05-18 21:10:44 +00:00
patches = [
# Remove absolute paths in Make-config (and unset variables so they can be set in preBuild)
./no-absolute-paths.patch
# Include new targets (like arm)
./make-archs.patch
2021-05-18 21:10:44 +00:00
];
postPatch = ''
# Ensure looks for nix-provided Carbon, not system frameworks
substituteInPlace unix/Make-arch \
--replace '-F/System/Library/Frameworks' ""
'';
2016-10-10 16:43:16 +00:00
installPhase = ''
cd ../compile/${arch}
mkdir -p "$out"/{bin,lib,include,share/doc/tachyon,share/tachyon}
cp tachyon "$out"/bin
cp libtachyon.* "$out/lib"
cd ../..
2020-06-01 04:29:20 +00:00
cp src/*.h "$out/include/"
2016-10-10 16:43:16 +00:00
cp Changes Copyright README "$out/share/doc/tachyon"
cp -r scenes "$out/share/tachyon/scenes"
'';
meta = {
description = "A Parallel / Multiprocessor Ray Tracing System";
license = lib.licenses.bsd3;
maintainers = [lib.maintainers.raskin];
platforms = with lib.platforms; linux ++ cygwin ++ darwin;
homepage = "http://jedi.ks.uiuc.edu/~johns/tachyon/";
2016-10-10 16:43:16 +00:00
};
}