cabal2nix icon indicating copy to clipboard operation
cabal2nix copied to clipboard

Address hinotify/hfsevents conflict

Open pikajude opened this issue 10 years ago • 2 comments

Everything in hackage-packages.nix that, according to Cabal, depends on either hfsevents or hinotify, depends on hinotify only according to nix. This causes build failures on Darwin unless the dependency is overridden. For an example, see fsnotify, which is intended to be a cross-platform file notification library but always tries to build hinotify.

pikajude avatar Feb 10 '15 21:02 pikajude

The problem is https://github.com/NixOS/cabal2nix/blob/a50090673759454fd45038bb4a4cab0831269765/src/Cabal2Nix/Generate.hs#L25. When Cabal files are compiled into a PackageDescription, cabal2nix must commit to one particular CPU, OS, and compiler version so that all those Cabal conditionals can be resolved. We chose to use Linux/x86_64 with GHC 7.8.4, because that's our most popular platform, but obviously this choice is wrong for people using Darwin and/or other versions of GHC.

There is no easy way to fix that. We could implement a super sophisticated compiler function, of course, that obsoletes finalizePackageDescription and translates a GenericPackageDescription directly into Nix, mapping all those Flags and conditionals into a meaningful functional representation, but that's not exactly a weekend project.

So far, our best best is to add overrides for those packages that are affected, really. It's not elegant, but I don't know a better solution for the time being. Suggestions are welcome!

peti avatar Feb 10 '15 21:02 peti

Nowadays you can pass the system explicitly (the default is inherited based on your local platform).

$ cabal2nix --system x86_64-darwin cabal://fsnotify
{ mkDerivation, async, base, containers, directory, filepath
, hfsevents, stdenv, tasty, tasty-hunit, temporary, text, time
, unix-compat
}:
mkDerivation {
  pname = "fsnotify";
  version = "0.2.1.1";
  sha256 = "146wsblhfwnbclzffxk6m43bqap3sgw332gs67030z6h5ab7anhp";
  libraryHaskellDepends = [
    async base containers directory filepath hfsevents text time
    unix-compat
  ];
  testHaskellDepends = [
    async base directory filepath tasty tasty-hunit temporary
    unix-compat
  ];
  homepage = "https://github.com/haskell-fswatch/hfsnotify";
  description = "Cross platform library for file change notification";
  license = stdenv.lib.licenses.bsd3;
}
$ cabal2nix --system x86_64-linux cabal://fsnotify
{ mkDerivation, async, base, containers, directory, filepath
, hinotify, stdenv, tasty, tasty-hunit, temporary, text, time
, unix-compat
}:
mkDerivation {
  pname = "fsnotify";
  version = "0.2.1.1";
  sha256 = "146wsblhfwnbclzffxk6m43bqap3sgw332gs67030z6h5ab7anhp";
  libraryHaskellDepends = [
    async base containers directory filepath hinotify text time
    unix-compat
  ];
  testHaskellDepends = [
    async base directory filepath tasty tasty-hunit temporary
    unix-compat
  ];
  homepage = "https://github.com/haskell-fswatch/hfsnotify";
  description = "Cross platform library for file change notification";
  license = stdenv.lib.licenses.bsd3;
}

(see the different between hinotify and hfsevents)

domenkozar avatar Aug 10 '17 13:08 domenkozar