dear-imgui.hs icon indicating copy to clipboard operation
dear-imgui.hs copied to clipboard

Marked as broken on nixpkgs

Open Cajunvoodoo opened this issue 1 year ago • 7 comments

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 avatar Sep 01 '23 20:09 Cajunvoodoo

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 avatar Sep 06 '23 21:09 Cajunvoodoo

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.

Cajunvoodoo avatar Sep 07 '23 13:09 Cajunvoodoo

@Cajunvoodoo does it work when using pkgs.fetchFromGitHub ?

TristanCacqueray avatar Sep 07 '23 13:09 TristanCacqueray

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.

Cajunvoodoo avatar Sep 07 '23 19:09 Cajunvoodoo

Did you ever figure this out?

spacekitteh avatar Jun 22 '24 00:06 spacekitteh

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.

Cajunvoodoo avatar Jun 22 '24 01:06 Cajunvoodoo

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

  • sdl + opengl3: https://github.com/TristanCacqueray/simple-dsp/blob/61f63a67ae4f8dcb9457e1929b56cbf7046f2526/flake.nix#L16-L29

  • glfw-wayland + vulkan: https://gitlab.com/TristanCacqueray/keid-vkguide/-/blob/bb13d8ef2e7dd3bd8db158ca38cba6e0d7faf316/flake.nix#L54-83

TristanCacqueray avatar Jun 22 '24 12:06 TristanCacqueray