Carp/default.nix

70 lines
2.6 KiB
Nix
Raw Normal View History

2019-09-21 01:35:57 +03:00
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }:
2019-09-21 00:25:53 +03:00
let
inherit (nixpkgs) pkgs;
f = { mkDerivation, ansi-terminal, base, blaze-html, blaze-markup
, cmark, cmdargs, containers, directory, edit-distance, filepath
, haskeline, HUnit, mtl, parsec, process, split, stdenv, text
, darwin, glfw3, SDL2, SDL2_image, SDL2_gfx, SDL2_mixer, SDL2_ttf
2020-05-08 23:47:55 +03:00
, clang , makeWrapper
2020-05-11 17:10:35 +03:00
, libXext, libXcursor, libXinerama, libXi, libXrandr, libXScrnSaver, libXxf86vm, libpthreadstubs, libXdmcp, libGL
2019-09-21 00:25:53 +03:00
}:
mkDerivation {
pname = "CarpHask";
version = "0.3.0.0";
src = ./.;
isLibrary = false;
isExecutable = true;
enableSharedLibraries = false;
enableSharedExecutables = false;
enableLibraryProfiling = false;
enableExecutableProfiling = false;
libraryHaskellDepends = [
ansi-terminal base blaze-html blaze-markup cmark containers
directory edit-distance filepath haskeline mtl parsec process split
text
];
2020-05-08 23:47:55 +03:00
pkgconfigDepends =
[ glfw3 SDL2 SDL2_image SDL2_gfx SDL2_mixer SDL2_ttf ]
2020-05-11 17:10:35 +03:00
++ stdenv.lib.optionals stdenv.isLinux [ libXext libXcursor libXinerama libXi libXrandr libXScrnSaver libXxf86vm libpthreadstubs libXdmcp libGL];
2019-09-21 00:25:53 +03:00
executableHaskellDepends = [
base cmdargs containers directory haskeline parsec process
2020-05-08 23:47:55 +03:00
clang
2019-09-21 00:25:53 +03:00
];
2020-05-08 23:47:55 +03:00
executableFrameworkDepends = with darwin.apple_sdk.frameworks; stdenv.lib.optionals stdenv.isDarwin [
2019-09-21 00:25:53 +03:00
Carbon Cocoa IOKit CoreFoundation CoreVideo IOKit ForceFeedback
];
2020-05-08 23:47:55 +03:00
buildDepends = [ makeWrapper ];
postInstall = ''
wrapProgram $out/bin/carp --set CARP_DIR $src --prefix PATH : ${clang}/bin
wrapProgram $out/bin/carp-header-parse --set CARP_DIR $src --prefix PATH : ${clang}/bin
'';
2019-09-21 00:25:53 +03:00
testHaskellDepends = [ base containers HUnit ];
testTarget = "CarpHask-test";
postCheck = ''
env CARP=dist/build/carp/carp ./run_carp_tests.sh
'';
enableParallelBuilding = true;
homepage = "https://github.com/eriksvedang/Carp";
license = stdenv.lib.licenses.asl20;
};
haskellPackages = if compiler == "default"
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler};
variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
drv = variant (haskellPackages.callPackage f {});
in
if pkgs.lib.inNixShell
then drv.env.overrideAttrs (o: {
2020-05-08 23:47:55 +03:00
buildInputs = o.buildInputs ++ [ haskellPackages.cabal-install pkgs.clang ];
2019-09-21 00:25:53 +03:00
})
else drv