A bit of context. I have a Haskell project foo managed with a flake. In the devShell.default.packages of foo, I want to use the executable of another Haskell project bar, also managed with a flake. However, I need to compile bar with the same version of ghc that I use in foo. Unfortunately, bar uses a different ghc in its packages.<system>.default (but it can compile with the version of ghc that I want). Thus, I cannot simply make bar an input of foo and put bar.packages.<system>.default in my devShell.default.packages.
Whats the best way to do this? Is there a way to do this purely using bar as a flake input?
Here is an idea, but its more complicated than I’d like and I can’t quite get it to work. Since I want to use bar in my devShell.default.packages, I need to make my own derivation of bar that uses my ghc version.
I can almost make a derivation with pkgs.haskell.packages.myghcversion.callCabal2nix "bar" source-of-bar. But then I need to pass this all the Haskell build dependencies of bar to actually produce a derivation. Further, the dependencies need to be in the format of an attribute set, associating the name of the dependency to the derivation to build it.
I can retrieve the Haskell build dependencies as a list by including bar as a flake input and accessing bar.packages.<system>.default.getBuildInputs.haskellBuildInputs. But I don’t know how to turn this into an attribute set properly. So I’m stuck here.
I would love to find a simpler way to do this. Or, if all else fails, make this callCabal2nix way work. Anybody have any ideas?