haskell-game / dear-imgui.hs

Haskell bindings to Dear ImGui, an immediate mode GUI toolkit
BSD 3-Clause "New" or "Revised" License
133 stars 31 forks source link

Marked as broken on nixpkgs #185

Open Cajunvoodoo opened 10 months ago

Cajunvoodoo commented 10 months ago

Currently, dear-imgui.hs is marked as broken on nixpkgs. Temporarily allowing broken packages gives the following error:

@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
configureFlags: --verbose --prefix=/nix/store/r0z0xjm7p1cdsz1am22rswl97y6fg5vq-dear-imgui-2.1.3 --libdir=$prefix/lib/$compiler --libsubdir=$abi/$libname --with-gcc=gcc --package-db=/build/tmp.qo7rfeAam4/packa>Using Parsec parser
Configuring dear-imgui-2.1.3...

Setup: Encountered missing or private dependencies:
megaparsec >=9.0 && <9.3

Ignoring dependency bounds with haskell-flake produces a different error:

error: builder for '/nix/store/5mr7mfnacvzynjizdr3xqkq488mk7ayh-source-dear-imgui-sdist.tar.gz.drv' failed with exit code 1;
       last 8 log lines:
       > unpacking source archive /nix/store/gfanl0krmlsgv2ij5x3nfslh2dfk1c7c-source-dear-imgui
       > source root is source-dear-imgui
       > Config file path source is default config file.
       > Config file not found: /build/source-dear-imgui/.config/cabal/config
       > Writing default configuration to /build/source-dear-imgui/.config/cabal/config
       > Error: cabal: sdist of dear-imgui-2.1.3: filepath wildcard 'imgui/*.h' does
       > not match any files.
       >
       For full logs, run 'nix log /nix/store/5mr7mfnacvzynjizdr3xqkq488mk7ayh-source-dear-imgui-sdist.tar.gz.drv'.
error: 1 dependencies of derivation '/nix/store/pjll751gmfh225wxiadrd94b90s7zc9q-dear-imgui-2.1.3.drv' failed to build

I am using pkgs.haskell.packages.ghc92 (ghc 9.2.8) for my project.

Cajunvoodoo commented 10 months ago

It appears the first issue (dependency bounds) is simply nixpkgs not having the required version, not a big deal.

The second issue, however, appears to be due to the imgui submodule. In the flake input, the following worked:

dear-imgui = {
  type = "git";
  submodules = true; # requires `type = "git"`
  flake = false;
  url = "https://github.com/haskell-game/dear-imgui.hs";
};

By default it appears flakes do not pull the submodules, which is why cabal could not find imgui/*.h. I do not know if this problem can be solved in a convenient way on the dear-imgui side, but it probably ought to be noted somewhere for inclusion in flakes. Is there any better place than the readme?

Cajunvoodoo commented 10 months ago

After looking into it further, it appears there is no general way to include submodules on self with flakes yet. All of the proposed solutions are either under debate, dropped, or are in development.

I guess this means the documentation should probably be updated to include this info for nix users.

The only other solution is cutting the submodule, but that seems like a lot more work. I don't see this package being freed of its "broken" status any other way.

TristanCacqueray commented 10 months ago

@Cajunvoodoo does it work when using pkgs.fetchFromGitHub ?

Cajunvoodoo commented 10 months ago

I'm not sure how that would work in the flake inputs field. I looked up the documentation and it says it uses fetchgit when fetchSubmodules=true;. Regardless, using fetchFromGitHub over whatever normal flakes do would only impact the user side of the library, not the broken status on nixpkgs.

I spent the last 4 hours or so working on both a fork of nixpkgs and of dear-imgui.hs to little avail. The closest I have gotten is from modifying nixpkgs, but the biggest issue is now finding all of the system dependencies. The following produces better results, but errors:

# in nixpkgs, configuration-common.nix
dear-imgui = overrideCabal (drv: {
  src = pkgs.fetchFromGitHub {
    owner = "haskell-game";
    repo = "dear-imgui.hs";
    sha256 = "";
    fetchSubmodules = true;
  };
   libraryPkgconfigDepends = with pkgs; [
    pkg-config
    gcc
    SDL2
    # ...
    ];
}

but it errors with "gcc: fatal error execv: Argument list too long." Looking into it, it appears this is still an open issue https://github.com/NixOS/nixpkgs/issues/41340.

Modifying dear-imgui.hs alongside it and pointing the above configuration to my fork resulted in similar errors. I can't think of a way to get around this, as adding packages to either will result in compilation failure. Why this occurs only for the nixpkgs version I have the faintest of clues. Hopefully someone with better nix-fu than me can provide some insight.

spacekitteh commented 2 weeks ago

Did you ever figure this out?

Cajunvoodoo commented 2 weeks ago

Not in nixpkgs, no, but I recall a while back finding some workaround. You may want to look at this override to get a working version of dear-imgui.hs. Hope this helps.

TristanCacqueray commented 1 week ago

For what its worth, here are the overrides I am using: