Carp/default.nix

80 lines
2.9 KiB
Nix
Raw Normal View History

2020-05-13 01:21:31 +03:00
{ nixpkgs ? import <nixpkgs> {}
, compiler ? "default"
, doBenchmark ? false
, profiling ? false
}:
2019-09-21 00:25:53 +03:00
let
inherit (nixpkgs) pkgs;
optionals = nixpkgs.stdenv.lib.optionals;
linuxOnly = optionals nixpkgs.stdenv.isLinux;
f = { mkDerivation, stdenv
, ansi-terminal, base, blaze-html, blaze-markup
, cmark, containers, directory, edit-distance, filepath
, haskeline, HUnit, mtl, optparse-applicative, parsec, process, split, text
2019-09-21 00:25:53 +03:00
, darwin, glfw3, SDL2, SDL2_image, SDL2_gfx, SDL2_mixer, SDL2_ttf
2020-05-13 01:21:31 +03:00
, ghc-prof-flamegraph
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;
2020-05-13 01:21:31 +03:00
enableLibraryProfiling = profiling;
enableExecutableProfiling = profiling;
2019-09-21 00:25:53 +03:00
libraryHaskellDepends = [
ansi-terminal base blaze-html blaze-markup cmark containers
directory edit-distance filepath haskeline mtl parsec process split
text
2020-05-13 01:21:31 +03:00
] ++ optionals profiling [ ghc-prof-flamegraph ];
2020-05-08 23:47:55 +03:00
pkgconfigDepends =
[ glfw3 SDL2 SDL2_image SDL2_gfx SDL2_mixer SDL2_ttf ]
++ linuxOnly [ libXext libXcursor libXinerama libXi libXrandr libXScrnSaver libXxf86vm libpthreadstubs libXdmcp libGL];
2019-09-21 00:25:53 +03:00
executableHaskellDepends = [
base containers directory haskeline optparse-applicative parsec process
2020-05-08 23:47:55 +03:00
clang
2019-09-21 00:25:53 +03:00
];
executableFrameworkDepends = with darwin.apple_sdk.frameworks; 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: {
buildInputs = with pkgs; o.buildInputs ++ [ haskellPackages.cabal-install clang gdb ]
++ linuxOnly [ flamegraph linuxPackages.perf tinycc ];
2019-09-21 00:25:53 +03:00
})
else drv