Skip to content

Commit 3cc4435

Browse files
committed
haskell-opencv.nix: filter out sources which aren't needed for building
1 parent b14eebb commit 3cc4435

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

haskell-opencv.nix

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{ mkDerivation
22
, stdenv
3+
, lib
34

45
, opencv3_1
56

@@ -36,7 +37,32 @@
3637
mkDerivation {
3738
pname = "opencv";
3839
version = "0.0.0";
39-
src = ./.;
40+
src = builtins.filterSource (path: type:
41+
# Filter out .cpp files under ./src generated by inline-c:
42+
!(lib.hasPrefix (toString (./. + "/src")) (dirOf path)
43+
&& lib.hasSuffix ".cpp" (baseNameOf path))
44+
45+
# Filter out generated images:
46+
&& !( type != "directory"
47+
&& ( (lib.hasSuffix "doc/generated" (dirOf path))
48+
|| (lib.hasSuffix "doc/generated/examples" (dirOf path))
49+
)
50+
)
51+
52+
# Filter out .nix files so that changing them doesn't necessarily cause a rebuild:
53+
&& !(lib.hasSuffix ".nix" (baseNameOf path))
54+
55+
# Filter out some other files or directories not needed for a build:
56+
&& !(builtins.elem (toString path) (map (p: toString (./. + "/${p}")) [
57+
"cabal.config"
58+
"Makefile"
59+
"README.md"
60+
".git"
61+
".gitignore"
62+
"examples"
63+
"dist"
64+
]))
65+
) ./.;
4066

4167
libraryHaskellDepends = [
4268
aeson
@@ -78,10 +104,6 @@ mkDerivation {
78104
"--with-ld=g++"
79105
];
80106

81-
preConfigure = ''
82-
rm -rf dist
83-
'';
84-
85107
homepage = "https://github.com/LumiGuide/haskell-opencv";
86108
license = stdenv.lib.licenses.bsd3;
87109
maintainers = [ "[email protected]" ];

0 commit comments

Comments
 (0)