4

I am attempting to run Haskell executables from the command line, following the example of this blog. My machine runs NixOS.

The blog is about compiling markdown literate haskell into html for publishing blog posts. One step in that process is to run the haskell program hscolour on the .lhs file to create a .mkd file with the code syntax-highlighted via html and css.

cat blah.lhs | hscolour -lit -css > blah.mkd

When I try to run this command, however, I get the following command not found error.

$ cat blah.lhs | hscolour -lit -css > blah.mkd                                                            
hscolour: command not found

I'm not sure whether this issue I'm having is specific to NixOS, or with making haskell executables available to the command line more broadly. How do I make haskell executables such as hscolour available from the command line?


I have tried running this command from within a nix-shell in which hscolour has been built. The hscolour command still was not found.

$ nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [hscolour])"
$ cat functor-proofs.lhs | hscolour -li
hscolour: command not found

2 Answers 2

6

Two things to know:

  1. You don't need GHC, you just need the executable from hscolour, which you can obtain as haskell.lib.justStaticExecutables haskellPackages.hscolour.

  2. The binary for hscolour is called HsColour, not hscolour.

To demonstrate:

$ nix-shell -p 'haskell.lib.justStaticExecutables haskellPackages.hscolour' --run 'HsColour --version'
HsColour 1.24
Sign up to request clarification or add additional context in comments.

Comments

2

I'll share an other approach I discovered shortly by looking for an executable on NixOS.

$ `nix-build --no-out-link "<nixpkgs>"   -A haskellPackages.hscolour`/bin/HsColour --version                         
HsColour 1.24

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.