mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
chore: Simplify default.nix (#1085)
* chore: Simplify default.nix * chore: Fix Darwin build
This commit is contained in:
parent
6f7aeaff73
commit
e0193f17bd
110
default.nix
110
default.nix
@ -1,80 +1,36 @@
|
|||||||
{ nixpkgs ? import <nixpkgs> {}
|
{ pkgs ? import <nixpkgs> {}
|
||||||
, compiler ? "default"
|
, profiling ? false
|
||||||
, doBenchmark ? false
|
|
||||||
, profiling ? false
|
|
||||||
, doCheck ? true
|
, doCheck ? true
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
odrv = with pkgs; with haskellPackages; developPackage {
|
||||||
inherit (nixpkgs) pkgs;
|
root = ./.;
|
||||||
|
name = "CarpHask";
|
||||||
optionals = nixpkgs.stdenv.lib.optionals;
|
modifier = lib.flip haskell.lib.overrideCabal (_: {
|
||||||
linuxOnly = optionals nixpkgs.stdenv.isLinux;
|
buildTools = [
|
||||||
|
cabal-install clang gdb
|
||||||
f = { mkDerivation, stdenv
|
ormolu hlint flamegraph ghc-prof-flamegraph
|
||||||
, ansi-terminal, open-browser, base, blaze-html, blaze-markup
|
] ++ lib.optionals stdenv.isLinux [ linuxPackages.perf tinycc zig ];
|
||||||
, cmark, containers, directory, edit-distance, filepath, hashable
|
pkgconfigDepends = [ SDL2 SDL2_image SDL2_mixer SDL2_ttf glfw ];
|
||||||
, haskeline, HUnit, mtl, optparse-applicative, parsec, process, split, text
|
enableLibraryProfiling = profiling;
|
||||||
, darwin, glfw3, SDL2, SDL2_image, SDL2_gfx, SDL2_mixer, SDL2_ttf
|
enableExecutableProfiling = profiling;
|
||||||
, ghc-prof-flamegraph, ormolu, hlint
|
enableSharedLibraries = false;
|
||||||
, clang , makeWrapper
|
enableSharedExecutables = false;
|
||||||
, libXext, libXcursor, libXinerama, libXi, libXrandr, libXScrnSaver, libXxf86vm, libpthreadstubs, libXdmcp, libGL
|
});
|
||||||
|
};
|
||||||
, cabal-install, gdb , flamegraph, linuxPackages, tinycc, zig
|
drv = with pkgs; odrv.overrideAttrs (o: {
|
||||||
}:
|
inherit doCheck;
|
||||||
mkDerivation {
|
buildInputs = o.buildInputs ++ [ makeWrapper pkgconfig ];
|
||||||
pname = "CarpHask";
|
postPatch = ''
|
||||||
version = "dev";
|
patchShebangs .
|
||||||
src = ./.;
|
'';
|
||||||
inherit doCheck doBenchmark;
|
postInstall = ''
|
||||||
isLibrary = false;
|
wrapProgram $out/bin/carp --set CARP_DIR $src --prefix PATH : ${clang}/bin
|
||||||
isExecutable = true;
|
wrapProgram $out/bin/carp-header-parse --set CARP_DIR $src --prefix PATH : ${clang}/bin
|
||||||
enableSharedLibraries = false;
|
'';
|
||||||
enableSharedExecutables = false;
|
postCheck = ''
|
||||||
enableLibraryProfiling = profiling;
|
env CARP=dist/build/carp/carp scripts/run_carp_tests.sh
|
||||||
enableExecutableProfiling = profiling;
|
'';
|
||||||
libraryHaskellDepends = [
|
enableParallelBuilding = true;
|
||||||
ansi-terminal open-browser base blaze-html blaze-markup cmark containers
|
});
|
||||||
directory edit-distance filepath haskeline mtl parsec process split
|
in drv
|
||||||
text hashable
|
|
||||||
] ++ optionals profiling [ ghc-prof-flamegraph ];
|
|
||||||
pkgconfigDepends =
|
|
||||||
[ glfw3 SDL2 SDL2_image SDL2_gfx SDL2_mixer SDL2_ttf ]
|
|
||||||
++ linuxOnly [ libXext libXcursor libXinerama libXi libXrandr libXScrnSaver libXxf86vm libpthreadstubs libXdmcp libGL];
|
|
||||||
executableHaskellDepends = [
|
|
||||||
base containers directory haskeline optparse-applicative parsec process
|
|
||||||
clang
|
|
||||||
];
|
|
||||||
executableToolDepends = optionals pkgs.lib.inNixShell (
|
|
||||||
[ cabal-install clang gdb ormolu hlint ]
|
|
||||||
++ optionals stdenv.isLinux [ flamegraph linuxPackages.perf tinycc zig ]
|
|
||||||
);
|
|
||||||
executableFrameworkDepends = with darwin.apple_sdk.frameworks; optionals stdenv.isDarwin [
|
|
||||||
Carbon Cocoa IOKit CoreFoundation CoreVideo IOKit ForceFeedback
|
|
||||||
];
|
|
||||||
buildDepends = [ makeWrapper ];
|
|
||||||
postPatch = ''
|
|
||||||
patchShebangs .
|
|
||||||
'';
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
testHaskellDepends = [ base containers HUnit ];
|
|
||||||
testTarget = "CarpHask-test";
|
|
||||||
postCheck = ''
|
|
||||||
env CARP=dist/build/carp/carp scripts/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};
|
|
||||||
drv = haskellPackages.callPackage f {};
|
|
||||||
|
|
||||||
in
|
|
||||||
if pkgs.lib.inNixShell then drv.env else drv
|
|
||||||
|
Loading…
Reference in New Issue
Block a user