However, it seems to have the same issue as the default Haskell template.
nix flake show github:mhwombat/hello-haskell-flake
error: cannot build '/nix/store/faz0ibrbnfa0c8zskmxfvxirpw205b18-cabal2nix-hello-haskell-flake.drv' during evaluation because the option 'allow-import-from-derivation' is disabled
(use '--show-trace' to show detailed location information)
I really like the way you’ve written it, though. I find it easier to understand than the template.
This is a big simplification, but the way I see it, there are two “camps” of people in the Nix community: Pro-IFD and Anti-IFD.
Pro-IFD: These are people that generally think IFD should be used for packaging things. Most Haskellers fall into this camp (given tools like haskell.nix and callCabal2nix), as well as users of the other FOO2nix tools.
Using IFD can often really simplify your day-to-day maintenance of Nix code. I fall into this camp, and I personally feel like it is an anti-pattern to try to do Haskell develop with Nix and not rely on something like haskell.nix or callCabal2nix.
Anti-IFD: These are people that think Nix should try to evolve without relying on the IFD functionality. There are a bunch of good reasons for not allowing IFD. You see evidence of this mindset with Nixpkgs/Hydra not allowing IFD, and flakes not allowing IFD by default for things like nix flake show.
cabal2nixWithoutIFD (and more generally, PureNix) is an attempt to replicate most of the functionality of cabal2nix, but implemented entirely in Nix. The idea came from poetry2nix, which works basically the same. This type of approach gives you all the benefits of something like cabal2nix, but without requiring IFD.
Although, in practice, cabal2nix relies on Cabal-the-library, which is incredibly complex. Porting the necessary functionality from Cabal to cabal2nixWithoutIFD would be quite an undertaking. My guess is that cabal2nixWithoutIFD will forever stay a neat proof-of-concept, and never become a tool that is actually used.
(edit: The above explanation paints people as either being pro-IFD or anti-IFD, but in practice almost everyone sees the benefits of IFD, and understands the drawbacks. Most people are firmly in the middle.)
Thank you so much for that explanation! I’m very interested in this issue now.
I’m trying an approach that I expect will probably fail, but will be a good learning experience for me. I am using cabal build directly in a flake, with a configuration that tells it not to try to connect to the Internet. For the moment, I have a simple Haskell program with no dependencies on anything except base. I’m just curious to see how far I’ll get.