Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskell opencv doesn't build anymore #47595

Closed
juliendehos opened this issue Oct 1, 2018 · 4 comments
Closed

haskell opencv doesn't build anymore #47595

juliendehos opened this issue Oct 1, 2018 · 4 comments

Comments

@juliendehos
Copy link
Contributor

Issue description

To run some haskell programs (which use opencv), I use the following shell.nix. This works fine with nixos-18.03, but it fails with more recent channels (nixos-18.09-beta, unstable).

# shell.nix
let

  config = {
    packageOverrides = pkgs: {
      haskellPackages = pkgs.haskellPackages.override {
        overrides = haskellPackagesNew: haskellPackagesOld: rec {
          opencv = pkgs.haskell.lib.dontCheck haskellPackagesOld.opencv;
        };
      };
    };
  };

  #rev = "18.03";           # succeeds
  rev = "18.09-beta";       # fails
  url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
  pkgs = import (fetchTarball url) { config = config; };

in

(pkgs.haskellPackages.mkDerivation {
  pname = "myexec";
  version = "0.1";
  src = ./.;
  isLibrary = false;
  isExecutable = true;
  executableHaskellDepends = with pkgs.haskellPackages; [
    opencv
  ];
  license = pkgs.stdenv.lib.licenses.mit;
}).env

The nix-shell command fails and prints the following error message.

...
[71 of 71] Compiling OpenCV.VideoIO.VideoWriter ( src/OpenCV/VideoIO/VideoWriter.hs, dist/build/OpenCV/VideoIO/VideoWriter.p_o )
/nix/store/h0lbngpv6ln56hjj59i6l77vxq25flbz-binutils-2.30/bin/ld: cannot find -lm
/nix/store/h0lbngpv6ln56hjj59i6l77vxq25flbz-binutils-2.30/bin/ld: cannot find -lgcc_s
/nix/store/h0lbngpv6ln56hjj59i6l77vxq25flbz-binutils-2.30/bin/ld: cannot find -lc
/nix/store/h0lbngpv6ln56hjj59i6l77vxq25flbz-binutils-2.30/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
builder for '/nix/store/wb015d0vf0rmyrzj2wn4pm70cjxybv3x-opencv-0.0.2.1.drv' failed with exit code 1
cannot build derivation '/nix/store/xgjjnl48aiq9ambfjvgkvr24prfh1bd3-ghc-8.4.3-with-packages.drv': 1 dependencies couldn't be built
error: build of '/nix/store/xgjjnl48aiq9ambfjvgkvr24prfh1bd3-ghc-8.4.3-with-packages.drv' failed

Technical details

$ nix-shell -p nix-info --run "nix-info -m"
warning: Nix search path entry '/home/julien/.nix-defexpr/channels' does not exist, ignoring
warning: Nix search path entry '/home/julien/.nix-defexpr/channels' does not exist, ignoring
 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.71, NixOS, 19.03pre153158.7df10f388da (Koi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.1.2`
 - channels(root): `"nixos-19.03pre153158.7df10f388da"`
warning: Nix search path entry '/home/julien/.nix-defexpr/channels' does not exist, ignoring
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@ocharles
Copy link
Contributor

I just ran into this on 18.09. @basvandijk - is LumiGuide/haskell-opencv@cd613e2 relevant here?

@ocharles
Copy link
Contributor

I can confirm the above commit fixes things. The following expression builds:

{ mkDerivation, aeson, base, base64-bytestring, bindings-DSL
, bytestring, Cabal, containers, criterion, data-default, deepseq
, directory, fetchgit, Glob, haskell-src-exts, inline-c
, inline-c-cpp, JuicyPixels, lens, linear, mtl, opencv, primitive
, QuickCheck, random, repa, stdenv, tasty, tasty-hunit
, tasty-quickcheck, template-haskell, text, transformers, vector
}:
mkDerivation {
  pname = "opencv";
  version = "0.0.2.1";
  src = fetchgit {
    url = "git://github.com/LumiGuide/haskell-opencv";
    sha256 = "1qaslz1pmc4nbg8cpnn5vzwzlxks9b9jipv2sz2fhr5lyrhm9718";
    rev = "65b9f38677aaf7f0bb63261b4ddf20802dc911f8";
  };
  postUnpack = "sourceRoot+=/opencv; echo source root reset to $sourceRoot";
  setupHaskellDepends = [ base Cabal ];
  libraryHaskellDepends = [
    aeson base base64-bytestring bindings-DSL bytestring containers
    data-default deepseq inline-c inline-c-cpp JuicyPixels linear mtl
    primitive repa template-haskell text transformers vector
  ];
  libraryPkgconfigDepends = [ opencv ];
  testHaskellDepends = [
    base bytestring containers data-default deepseq directory Glob
    haskell-src-exts JuicyPixels lens linear primitive QuickCheck
    random repa tasty tasty-hunit tasty-quickcheck template-haskell
    text transformers vector
  ];
  benchmarkHaskellDepends = [
    base bytestring criterion linear repa vector
  ];
  hardeningDisable = [ "bindnow" ];
  homepage = "https://github.com/LumiGuide/haskell-opencv";
  description = "Haskell binding to OpenCV-3.x";
  license = stdenv.lib.licenses.bsd3;
}

This is generated by cabal2nix, and then setting configureFlags = [];.

@juliendehos
Copy link
Contributor Author

Yes, the following example works using your nix expression (opencvhs.nix). Thank you very much.

# shell.nix
let
  config = {
    packageOverrides = pkgs: rec {
      _opencv3 = (pkgs.opencv3.override {
        enableGtk3 = true;
      }).overrideDerivation (attrs: {
        doCheck = false;
      });
      haskellPackages = pkgs.haskellPackages.override {
        overrides = haskellPackagesNew: haskellPackagesOld: rec {
          opencv = pkgs.haskell.lib.dontCheck (
            haskellPackagesNew.callPackage ./opencvhs.nix {
              opencv = _opencv3;
            });
          };
        };
      };
    };
  rev = "18.09";
  url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
  pkgs = import (fetchTarball url) { inherit config; };
in
(pkgs.haskellPackages.mkDerivation {
  pname = "myexec";
  version = "0.1";
  src = ./.;
  isLibrary = false;
  isExecutable = true;
  executableHaskellDepends = with pkgs.haskellPackages; [
    opencv
  ];
  license = pkgs.stdenv.lib.licenses.mit;
}).env
-- image_display.hs
import Control.Monad ( void )
import qualified OpenCV as CV
import qualified Data.ByteString as B
import System.Environment (getArgs)
main :: IO ()
main = do
    args <- getArgs
    if null args
    then putStrLn "missing image filename"
    else do
        let filename = head args
        img <- CV.imdecode CV.ImreadUnchanged <$> B.readFile filename
        CV.withWindow "image display" $ \window -> do
            CV.imshow window img
            void $ CV.waitKey 0

@ocharles ocharles reopened this Oct 16, 2018
@ocharles
Copy link
Contributor

Reopening because it's still broken in nixpkgs.

typetetris added a commit to typetetris/nixpkgs that referenced this issue Nov 10, 2018
applied patch can be removed, when
LumiGuide/haskell-opencv@cd613e2
hits hackage and later nixpkgs.
@peti peti closed this as completed in 5966c56 Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants