Description
cloc . --exclude-dir=materialized
gives
739 text files.
571 unique files.
171 files ignored.
github.com/AlDanial/cloc v 1.96 T=0.79 s (723.5 files/s, 129753.4 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
diff 140 2235 10095 49948
Nix 247 1634 5573 19161
Bourne Shell 6 161 438 3333
Haskell 77 472 295 2691
Markdown 43 823 0 2512
JSON 14 0 0 2271
YAML 22 77 135 421
XML 14 13 0 58
TOML 3 0 0 17
C/C++ Header 2 6 2 11
C 1 3 0 4
JavaScript 2 1 7 4
-------------------------------------------------------------------------------
SUM: 571 5425 16545 80431
-------------------------------------------------------------------------------
haskell.nix is a Nix framework only for Haskell, yet it's so complex. ~20k lines of Nix, ~50k lines of patches, etc.
There's a reason for every single line of code (obviously), yet, looking at it from the big picture, it's not clear
why we need so much code to compile Haskell using GHC.
The patches are obviously not needed, every single patch that is still necessary should be upstreamed.
Perhaps there was a culture of working around upstream rather than attempting to fix upstream?
Without being deeply intimate with most of the codebase, could haskell.nix be simpler if we
- Tried to fix the issues in GHC/Cabal that make it hard to build, and
- Drop everything legacy?
Other projects for reference:
- https://discourse.nixos.org/t/announcing-stacklock2nix-easily-build-a-haskell-project-that-contains-a-stack-yaml-lock-file/23563
- https://homotopic.tech/post/horizon-tutorial-part-1.html https://gitlab.homotopic.tech/horizon/horizon-platform
My motivation is that it's quite frustrating to deal with building Haskell code. There's no good solution really. The above two projects don't fix the problem either, they use the code from Nixpkgs which is quite complex too.
If we think about the problem from first principles, we want to be able to compile Haskell modules, that depends on other Haskell modules (perhaps from the same project or another project), and eventually turn that into either a (shared) library or executable.
That library or executable might need other dependencies, some of which are necessary because of Haskell dependencies (c-bits, pkg-config, etc.). We additionally want the (obvious) ability to cross-compile.
Cross-compilation is mainly complicated because GHC only supports targetting one platform at a time (IIRC) like GCC, etc.. Nixpkgs has also had to workaround this issue resulting in complicated code for GCC, resulting in the build-host-target platform triple, when really it ought to be just build-host.
If rather than using Nix to orchestrate Cabal and GHC, could we not attempt to make Cabal nix-native as also mentioned in NixOS/rfcs#134 (comment) (this might necessarily involve using ca-derivations and dynamic-derivations)?
In the end, I honestly don't think there's much code to reuse from the current haskell.nix, but I doubt anyone is satisfied with the status quo. It is not fun to use haskell.nix, or to work with Haskell, because of the tooling.