Carp/default.nix

81 lines
3.1 KiB
Nix
Raw Normal View History

2020-05-13 01:21:31 +03:00
{ nixpkgs ? import <nixpkgs> {}
, compiler ? "default"
, doBenchmark ? false
, profiling ? false
2020-05-12 21:24:40 +03:00
, doCheck ? true
2020-05-13 01:21:31 +03:00
}:
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, open-browser, base, blaze-html, blaze-markup
, cmark, containers, directory, edit-distance, filepath, hashable
, 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
, ghc-prof-flamegraph, ormolu, hlint
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
2020-11-19 00:23:24 +03:00
, cabal-install, gdb , flamegraph, linuxPackages, tinycc, zig
2019-09-21 00:25:53 +03:00
}:
mkDerivation {
pname = "CarpHask";
2020-11-14 17:28:17 +03:00
version = "dev";
2019-09-21 00:25:53 +03:00
src = ./.;
2020-05-12 21:24:40 +03:00
inherit doCheck doBenchmark;
2019-09-21 00:25:53 +03:00
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 open-browser base blaze-html blaze-markup cmark containers
2019-09-21 00:25:53 +03:00
directory edit-distance filepath haskeline mtl parsec process split
text hashable
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
];
2020-11-19 00:23:24 +03:00
executableToolDepends = optionals pkgs.lib.inNixShell (
[ cabal-install clang gdb ormolu hlint ]
2020-11-19 00:23:24 +03:00
++ optionals stdenv.isLinux [ flamegraph linuxPackages.perf tinycc zig ]
);
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 ];
2020-11-14 17:28:17 +03:00
postPatch = ''
patchShebangs .
'';
2020-05-08 23:47:55 +03:00
postInstall = ''
2020-11-14 17:28:17 +03:00
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
2020-05-08 23:47:55 +03:00
'';
2019-09-21 00:25:53 +03:00
testHaskellDepends = [ base containers HUnit ];
testTarget = "CarpHask-test";
postCheck = ''
2020-11-14 17:28:17 +03:00
env CARP=dist/build/carp/carp scripts/run_carp_tests.sh
2019-09-21 00:25:53 +03:00
'';
enableParallelBuilding = true;
homepage = "https://github.com/eriksvedang/Carp";
license = stdenv.lib.licenses.asl20;
};
haskellPackages = if compiler == "default"
2020-11-19 00:23:24 +03:00
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler};
drv = haskellPackages.callPackage f {};
2019-09-21 00:25:53 +03:00
2020-11-19 00:23:24 +03:00
in
if pkgs.lib.inNixShell then drv.env else drv