-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdefault.nix
102 lines (92 loc) · 3.59 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
92
93
94
95
96
97
98
99
100
101
102
# CAUTION! a spelling mistake in arg string is ignored silently.
#
# nix-shell --argstr c2nix "--flag examples-sdl"
# To use ghc-8.6.5
# nix-shell --argstr compiler "ghc865"
{
nixpkgs ?
import (builtins.fetchTarball
https://github.com/NixOS/nixpkgs/archive/refs/tags/22.05.tar.gz)
{}
, compiler ? "ghc922"
, 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" + " " + c2nix;
mkHaskellPackages = inShell:
haskellPackages.override {
# We could disbale doCheck on all like this, but it would make the
# whole world rebuild, we can't use the binary cache
#packageSetConfig = self: super: {
# mkDerivation = drv: super.mkDerivation (drv // {
# doCheck = false;
# });
#};
overrides = self: super:
with nixpkgs.haskell.lib;
{
streaming-benchmarks =
mkPackage super "streaming-benchmarks"
./. flags inShell;
streamly =
nixpkgs.haskell.lib.overrideCabal
(super.callHackageDirect
{ pkg = "streamly";
ver = "0.8.3";
sha256 = "sha256-A6/S/yvmOXVabVAR6x4a/XYszzeogSU4vOuyLLSGFvE=";
} {})
(old:
{ librarySystemDepends =
if builtins.currentSystem == "x86_64-darwin"
then [nixpkgs.darwin.apple_sdk.frameworks.Cocoa]
else [];
enableLibraryProfiling = false;
doHaddock = false;
});
lockfree-queue =
super.callHackageDirect
{ pkg = "lockfree-queue";
ver = "0.2.4";
sha256 = "1bj9agy3x0yjbscpjgn96gpnj4lvkh39spjvy3jnrr3a42v3ynw7";
} {};
#fusion-plugin =
# super.callHackageDirect
# { pkg = "fusion-plugin";
# ver = "0.2.3";
# sha256 = "073wbhdxj1sh5160blaihbzkkhabs8s71pqhag16lvmgbb7a3hla";
# } {};
};
};
hspkgs = mkHaskellPackages true;
shell = hspkgs.shellFor {
packages = p:
[ p.streaming-benchmarks
];
doBenchmark = true;
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).streaming-benchmarks