NixOS / cabal2nix

Generate Nix build instructions from a Cabal file
https://haskell4nix.readthedocs.io
Other
355 stars 154 forks source link

Support single-file Haskell script #613

Closed eownerdead closed 9 months ago

eownerdead commented 9 months ago

With cabal run all dependencies will be built. However, if Nix cache can be used Haskell will become more useful for scripting language, like Python. Also, it may be more convenient if it can be executable like cabal2nix --run ./script.hs. Sorry if this is already supported or duplicated. Regards.

sternenseemann commented 9 months ago

You can use nix-shell's interpreter capabilities for this together with ghcWithPackages from nixpkgs for providing the dependencies and ghc.

eownerdead commented 8 months ago

But... we can't run them without Nix, need to rewrite cabal scripts, and probably can't package them. Sorry for the late response🙏

sternenseemann commented 8 months ago

@eownerdead cabal2nix won't be able to give you a solution that works without Nix. It is merely a tool that generates Nix code. The cabal shebang is your best shot then.