@@ -0,0 +1,103 @@
1+# CAUTION! a spelling mistake in arg string is ignored silently.
3+# To include benchmark deps use:
4+# nix-shell --argstr c2nix "--benchmark --flag fusion-plugin"
6+# To build the chart executable for running bench.sh use:
7+# nix-shell --argstr c2nix "--flag dev" --run "cabal build chart --flag dev"
10+# nix-shell --argstr compiler "ghc865"
14+ import (builtins.fetchTarball https://github.com/composewell/nixpkgs/archive/01dd2b4e738.tar.gz)
15+ # fusion-plugin is marked as broken
16+ { config.allowBroken = true;}
17+, compiler ? "default"
18+, c2nix ? "" # cabal2nix CLI options
20+#, sources ? [] # e.g. [./. ./benchmark]
21+#, hdeps ? [] # e.g. [time, mtl]
22+#, deps ? [] # e.g. [SDL2]
25+ if compiler == "default"
26+ then nixpkgs.haskellPackages
27+ else nixpkgs.haskell.packages.${compiler};
29+ # we can possibly avoid adding our package to HaskellPackages like
30+ # in the case of nix-shell for a single package?
31+ mkPackage = super: pkg: path: opts: inShell:
32+ let orig = super.callCabal2nixWithOptions pkg path opts {};
34+ # Avoid copying the source directory to nix store by using
36+ then orig.overrideAttrs (oldAttrs: { src = null; })
39+ mkHaskellPackages = inShell:
40+ haskellPackages.override {
41+ # We could disbale doCheck on all like this, but it would make the
42+ # whole world rebuild, we can't use the binary cache
43+ #packageSetConfig = self: super: {
44+ # mkDerivation = drv: super.mkDerivation (drv // {
48+ overrides = self: super:
49+ with nixpkgs.haskell.lib;
51+ streamly = mkPackage super "streamly" ./. c2nix inShell;
52+ streamly-benchmarks =
53+ mkPackage super "streamly-benchmarks"
54+ ./benchmark c2nix inShell;
56+ # Example to Use a different version of a package
57+ #QuickCheck = self.QuickCheck_2_14;
59+ # Example to disable tests if tests fail or take too long
60+ # or to use different configure flags if needed
62+ # XXX We need the ability to disable doCheck on all
63+ # those packages that are being built locally and
64+ # not fetched from the cache. Running tests could do
65+ # nasty things to the machine e.g. some tests even
66+ # listen for incoming connections on the network.
68+ # super.selective.overrideAttrs (oldAttrs:
71+ # oldAttrs.configureFlags ++ ["--disable-tests"];
76+ drv = mkHaskellPackages true;
78+ shell = drv.shellFor {
81+ p.streamly-benchmarks
83+ # some dependencies of hoogle fail to build with quickcheck-2.14
84+ # We should use hoogle as external tool instead of building it here
87+ # XXX On macOS cabal2nix does not seem to generate a dependency on
90+ if builtins.currentSystem == "x86_64-darwin"
91+ then [nixpkgs.darwin.apple_sdk.frameworks.Cocoa]
93+ # Use a better prompt
95+ if test -n "$PS_SHELL"
97+ export PS1="$PS_SHELL\[$bldred\](nix)\[$txtrst\] "
101+in if nixpkgs.lib.inNixShell
103+ else (mkHaskellPackages false).streamly