-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
91 lines (82 loc) · 3.16 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# CAUTION! a spelling mistake in arg string is ignored silently.
#
# To use ghc-8.6.5
# nix-shell --argstr compiler "ghc865"
{
nixpkgs ?
import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/refs/tags/21.05.tar.gz)
{}
, compiler ? "default"
, c2nix ? "" # cabal2nix CLI options
# TODO
#, sources ? [] # e.g. [./. ./benchmark]
#, hdeps ? [] # e.g. [time, mtl]
#, deps ? [] # e.g. [SDL2]
}:
let haskellPackages =
if compiler == "default"
then nixpkgs.haskellPackages
else nixpkgs.haskell.packages.${compiler};
# we can possibly avoid adding our package to HaskellPackages like
# in the case of nix-shell for a single package?
mkPackage = super: pkg: path: opts: inShell:
let orig = super.callCabal2nixWithOptions pkg path opts {};
in if inShell
# Avoid copying the source directory to nix store by using
# src = null.
then orig.overrideAttrs (oldAttrs: { src = null; })
else orig;
flags = "--benchmark --flag fusion-plugin" + " " + c2nix;
mkHaskellPackages = inShell:
haskellPackages.override {
overrides = self: super:
with nixpkgs.haskell.lib;
{
streamly-lz4 = mkPackage super "streamly-lz4" ./. flags inShell;
streamly =
nixpkgs.haskell.lib.overrideCabal
(super.callHackageDirect
{ pkg = "streamly";
ver = "0.8.2";
sha256 = "0jhsdd71kqw0k0aszg1qb1l0wbxl1r73hsmkdgch4vlx43snlc8a";
} {})
(old:
{ librarySystemDepends =
if builtins.currentSystem == "x86_64-darwin"
then [nixpkgs.darwin.apple_sdk.frameworks.Cocoa]
else [];
enableLibraryProfiling = false;
doHaddock = false;
});
unicode-data =
super.callHackageDirect
{ pkg = "unicode-data";
ver = "0.3.0";
sha256 = "0izxxk7qgq22ammzmwc4cs4nlhzp7y55gzyas2a8bzhdpac1j7yx";
} {};
tasty-bench =
super.callHackageDirect
{ pkg = "tasty-bench";
ver = "0.3";
sha256 = "0na1q52zr8p1zz8hby4242yjr2zma3js4n91avl7ibsa2y51vrc4";
} {};
};
};
drv = mkHaskellPackages true;
shell = drv.shellFor {
packages = p:
[ p.streamly-lz4
];
doBenchmark = true;
# Use a better prompt
shellHook = ''
export CABAL_DIR="$(pwd)/.cabal.nix"
if test -n "$PS_SHELL"
then
export PS1="$PS_SHELL\[$bldred\](nix)\[$txtrst\] "
fi
'';
};
in if nixpkgs.lib.inNixShell
then shell
else (mkHaskellPackages false).streamly-lz4