forked from YPares/porcupine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
133 lines (108 loc) · 3.5 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
Workflow:
### Global
```
$ nix-shell
```
This will open a nix-shell with all the dependencies for all the
porcupine packages. This will also generates the cabal files and
cabal.project needed for all subproject.
```
$ cabal new-repl porcupine-s3
```
will open a ghci with porcupine-s3 in scope.
If you change anything to a dependency, you must reload the cabal
new-repl!
### Local
```
# Create a shell with all dependencies for porcupine-s3
nix-shell -A porcupine-s3.env
cd porcupine-s3
# build the cabal file
hpack
# start a repl
cabal new-repl
```
A few notes:
- You must restart your nix-shell to reload dependencies. For example,
if you change something in docrecords when working in the
porcupine-http shell, changes in docrecords and porcupine-core will
be accounted for on next nix-shell restart
- Nix caching is based on directory content, so any leftover file
(such as the generated .cabal) will invalidate it. This can be
extended by source filtering
*/
{ withHoogle ? false }:
let
porcupineSources = {
docrecords = ./docrecords;
reader-soup = ./reader-soup;
porcupine-core = ./porcupine-core;
porcupine-s3 = ./porcupine-s3;
porcupine-http = ./porcupine-http;
};
overlayHaskell = _:pkgs:
let
funflowSource = pkgs.fetchFromGitHub {
owner = "tweag";
repo = "funflow";
rev = "3166c357cd455607e4b5081a1019557e7bbf99f6"; # hoistFlowEff branch
sha256 = "1ygds96ph6mdrjm8cmq7yrghp9f6y5kswii9p5jp2byg8n4p6z0a";
};
monadBayesSource = pkgs.fetchFromGitHub {
owner = "tweag"; # Using our fork until https://github.com/adscib/monad-bayes/pull/54 is merged
repo = "monad-bayes";
rev = "ffd695379fefc056e99c43e3ca4d79be9a6372af";
sha256 = "1qikvzpkpm255q3mgpc0x9jipxg6kya3pxgkk043vk25h2j11l0p";
};
extendWithPorcupinePackages = self: _:
pkgs.lib.mapAttrs (name: src:
self.callCabal2nixWithOptions name src "--flag=useMonadBayes" {})
porcupineSources;
inherit (pkgs.haskell.lib) doJailbreak dontCheck;
in {
haskellPackages =
(pkgs.haskellPackages.override {
overrides = self: super: rec {
streaming-conduit = doJailbreak super.streaming-conduit;
# hedis checks take too long, so they are disabled:
hedis = dontCheck super.hedis;
# vinyl hasn't been updated for hspec >= 2.7:
vinyl = dontCheck super.vinyl;
hvega = super.hvega_0_4_1_0;
monad-bayes = self.callCabal2nix "monad-bayes" monadBayesSource {};
funflow = dontCheck (self.callCabal2nix "funflow" "${funflowSource}/funflow" {});
# Check are failing for funflow, this should be investigated
};
}).extend extendWithPorcupinePackages;
};
# Nixpkgs clone
pkgs = import ./nixpkgs.nix {
config = {
allowBroken = true; # for a few packages, such as streaming-conduit
};
overlays = [ overlayHaskell ];
};
porcupinePkgs = builtins.mapAttrs (x: _: pkgs.haskellPackages.${x}) porcupineSources;
# The final shell
shell = pkgs.haskellPackages.shellFor {
packages = _: builtins.attrValues porcupinePkgs;
nativeBuildInputs = [pkgs.cabal-install];
withHoogle = withHoogle;
# Generates the cabal and cabal project file
shellHook =
''
echo "packages:" > cabal.project
for i in ${toString (builtins.attrNames porcupineSources)}
do
hpack $i
echo " $i" >> cabal.project
done
'';
};
# this derivation contains the shell and all the porcupine package in
# direct access
in
{
inherit shell;
} // porcupinePkgs