-
Notifications
You must be signed in to change notification settings - Fork 44
/
overlay.nix
146 lines (137 loc) · 4.61 KB
/
overlay.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
134
135
136
137
138
139
140
141
142
143
144
145
146
enableOpencv4 : final : previous : with final.lib; with final.haskell.lib;
let
handleOpencv4 = drv : if enableOpencv4 then enableCabalFlag drv "opencv4" else drv;
useOpencvHighgui = drv : overrideCabal drv (_drv: {
libraryPkgconfigDepends = [
(if enableOpencv4
then final.opencv4_highgui
else final.opencv3_highgui)
];
});
haskellOverrides = self: super:
let
addBuildToolsInShell = drv : overrideCabal drv (drv : optionalAttrs inNixShell {
buildTools = (drv.buildTools or []) ++ (with self; [
cabal-install
stack
]);
});
in {
opencv = handleOpencv4 (addBuildToolsInShell (doBenchmark (overrideCabal (super.callCabal2nix "opencv" ./opencv {}) (drv : {
src = final.runCommand "opencv-src"
{ files = final.lib.sourceByRegex ./opencv [
"^src$"
"^src/.*"
"^include$"
"^include/.*"
"^test$"
"^test/.*"
"^bench$"
"^bench/.*"
"^opencv.cabal$"
"^Setup.hs$"
];
doc = ./doc;
data = ./data;
LICENSE = ./LICENSE;
} ''
mkdir -p $out
cp -r $files/* $out
cp -r $doc $out/doc
cp -r $data $out/data
cp $LICENSE $out/LICENSE
'';
shellHook = ''
export hardeningDisable=bindnow
'';
} // optionalAttrs enableOpencv4 {
libraryPkgconfigDepends = [ final.opencv4 ];
}))));
opencv_highgui = useOpencvHighgui self.opencv;
opencv-examples =
(addBuildToolsInShell (overrideCabal (super.callCabal2nix "opencv-examples" ./opencv-examples {}) (_drv : {
src = final.runCommand "opencv-examples-src"
{ files = final.lib.sourceByRegex ./opencv-examples [
"^src$"
"^src/.*"
"^lib$"
"^lib/.*"
"^opencv-examples.cabal$"
];
data = ./data;
LICENSE = ./LICENSE;
} ''
mkdir -p $out
cp -r $files/* $out
cp -r $data $out/data
cp $LICENSE $out/LICENSE
'';
}))).override { opencv = self.opencv_highgui; };
opencv-extra =
handleOpencv4 (addBuildToolsInShell (overrideCabal (super.callCabal2nix "opencv-extra" ./opencv-extra {}) (_drv : {
src = final.runCommand "opencv-extra-src"
{ files = final.lib.sourceByRegex ./opencv-extra [
"^include$"
"^include/.*"
"^src$"
"^src/.*"
"^opencv-extra.cabal$"
"^Setup.hs$"
];
doc = ./doc;
data = ./data;
LICENSE = ./LICENSE;
} ''
mkdir -p $out
cp -r $files/* $out
cp -r $doc $out/doc
cp -r $data $out/data
cp $LICENSE $out/LICENSE
'';
shellHook = ''
export hardeningDisable=bindnow
'';
# TODO (BvD): This should be added by cabal2nix. Fix this upstream.
libraryPkgconfigDepends = [
(if enableOpencv4
then final.opencv4
else final.opencv3)
];
})));
opencv-extra_highgui = (useOpencvHighgui self.opencv-extra).override {
opencv = self.opencv_highgui;
};
opencv-extra-examples =
(addBuildToolsInShell (overrideCabal (super.callCabal2nix "opencv-extra-examples" ./opencv-extra-examples {}) (_drv : {
src = final.runCommand "opencv-extra-examples-src"
{ files = final.lib.sourceByRegex ./opencv-extra-examples [
"^src$"
"^src/.*"
"^opencv-extra-examples.cabal$"
];
data = ./data;
LICENSE = ./LICENSE;
} ''
mkdir -p $out
cp -r $files/* $out
cp -r $data $out/data
cp $LICENSE $out/LICENSE
'';
}))).override {
opencv = self.opencv_highgui;
opencv-extra = self.opencv-extra_highgui;
};
};
in {
haskell = previous.haskell // {
packageOverrides = self: super:
previous.haskell.packageOverrides self super //
haskellOverrides self super;
};
opencv3_highgui = previous.opencv3.override {
enableGtk3 = !final.stdenv.isDarwin;
};
opencv4_highgui = previous.opencv4.override {
enableGtk3 = !final.stdenv.isDarwin;
};
}