Skip to content

Commit

Permalink
nix: Use nixos-23.05, remove remnants of opencv3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
nh2 committed Sep 7, 2023
1 parent ebee8cd commit 86cbb09
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 31 deletions.
4 changes: 2 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ nixpkgs ? import ./nixpkgs.nix, enableOpencv4 ? false
{ nixpkgs ? import ./nixpkgs.nix
, system ? builtins.currentSystem
}:
import nixpkgs {
inherit system;
overlays = [ (import ./overlay.nix enableOpencv4) ];
overlays = [ (import ./overlay.nix) ];
}
12 changes: 6 additions & 6 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-unstable",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"branch": "nixos-23.05",
"description": " Nix Packages collection & NixOS",
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs-channels",
"rev": "8d1510abfb592339e13ce8f6db6f29c1f8b72924",
"sha256": "0i4jscq2qy2vn9kr8ix9gr8ncf9dss24y09jrqhlpcpryi4i98dc",
"repo": "nixpkgs",
"rev": "da5adce0ffaff10f6d0fee72a02a5ed9d01b52fc",
"sha256": "sha256-32EnPCaVjOiEERZ+o/2Ir7JH9pkfwJZJ27SKHNvt4yk=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/8d1510abfb592339e13ce8f6db6f29c1f8b72924.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/da5adce0ffaff10f6d0fee72a02a5ed9d01b52fc.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
24 changes: 7 additions & 17 deletions overlay.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
enableOpencv4 : final : previous : with final.lib; with final.haskell.lib;
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)
final.opencv4_highgui
];
});

Expand All @@ -19,7 +15,7 @@ let
]);
});
in {
opencv = handleOpencv4 (addBuildToolsInShell (doBenchmark (overrideCabal (super.callCabal2nix "opencv" ./opencv {}) (drv : {
opencv = addBuildToolsInShell (doBenchmark (overrideCabal (super.callCabal2nix "opencv" ./opencv {}) (drv : {
src = final.runCommand "opencv-src"
{ files = final.lib.sourceByRegex ./opencv [
"^src$"
Expand All @@ -46,9 +42,8 @@ let
shellHook = ''
export hardeningDisable=bindnow
'';
} // optionalAttrs enableOpencv4 {
libraryPkgconfigDepends = [ final.opencv4 ];
}))));
})));

opencv_highgui = useOpencvHighgui self.opencv;

Expand All @@ -73,7 +68,7 @@ let
}))).override { opencv = self.opencv_highgui; };

opencv-extra =
handleOpencv4 (addBuildToolsInShell (overrideCabal (super.callCabal2nix "opencv-extra" ./opencv-extra {}) (_drv : {
addBuildToolsInShell (overrideCabal (super.callCabal2nix "opencv-extra" ./opencv-extra {}) (_drv : {
src = final.runCommand "opencv-extra-src"
{ files = final.lib.sourceByRegex ./opencv-extra [
"^include$"
Expand All @@ -98,11 +93,9 @@ let
'';
# TODO (BvD): This should be added by cabal2nix. Fix this upstream.
libraryPkgconfigDepends = [
(if enableOpencv4
then final.opencv4
else final.opencv3)
final.opencv4
];
})));
}));

opencv-extra_highgui = (useOpencvHighgui self.opencv-extra).override {
opencv = self.opencv_highgui;
Expand Down Expand Up @@ -137,9 +130,6 @@ in {
haskellOverrides self super;
};

opencv3_highgui = previous.opencv3.override {
enableGtk3 = !final.stdenv.isDarwin;
};
opencv4_highgui = previous.opencv4.override {
enableGtk3 = !final.stdenv.isDarwin;
};
Expand Down
15 changes: 9 additions & 6 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resolver: lts-20.26
resolver: lts-20.26 # ghc-9.2.8
# resolver: lts-20.11 # ghc-9.2.5
packages:
- opencv/
- opencv-examples/
Expand All @@ -12,12 +13,14 @@ packages:

allow-newer: true

extra-lib-dirs:
- /usr/local/lib

nix:
path: [ "nixpkgs=https://github.com/NixOS/nixpkgs/archive/8d1510abfb592339e13ce8f6db6f29c1f8b72924.tar.gz" ]
packages: [ zlib pkgconfig opencv3 ]
path: [ "nixpkgs=https://github.com/NixOS/nixpkgs/archive/da5adce0ffaff10f6d0fee72a02a5ed9d01b52fc.tar.gz" ] # nixos-22.11 with opencv4-4.7, and providing ghc-9.2.8
# path: [ "nixpkgs=https://github.com/NixOS/nixpkgs/archive/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b.tar.gz" ] # nixos-22.11 with opencv4-4.6, and providing ghc-9.2.5
packages:
- zlib
- gmp
- pkg-config
- opencv4

# Uncomment if you wish to use Docker integration
# See README.md for further information.
Expand Down

0 comments on commit 86cbb09

Please sign in to comment.