Using nix, we provide a set of common tools for haskell development. In general, for a given tool, we provide two benefits over direct usage:
- The tool itself i.e. no external dependencies required other than
nix
. - Common logic "on top" that is useful.
For example, for ormolu
, not only do we provide the executable itself, we also run it recursively on all files in a given directory. The default behavior is for ormolu
to run on files individually, so we judge this to be an ergonomic improvement.
While nix-hs-tools
is useful in a pinch, we sometimes want more granularity, e.g. pinning a project to a tool's specific version, or loading a general development shell. For these use-cases, see:
- Haskell flake utils: https://github.com/tbidne/nix-hs-utils
- Haskell development shells: https://github.com/tbidne/nix-hs-shells
In the usage descriptions, <args>
references tool-specific arguments that are passed-through. For example, in ormolu
's usage:
nix run github:tbidne/nix-hs-tools#ormolu -- [--dir PATH] <args>
--dir
is specific to our nixified tool (see ormolu for details). All other arguments (e.g. --mode check
) are ormolu-specific arguments that are passed to the ormolu executable.
Furthermore, each tool has a "help" page that is retrieved with --nh-help
, showing the usage.
$ nix run github:tbidne/nix-hs-tools#ormolu -- --nh-help
usage: nix run github:tbidne/nix-hs-tools#ormolu -- [--dir PATH] <args>
The version can also be fixed e.g.
nix run github:tbidne/nix-hs-tools/0.9.0.1#<tool> -- <args>
Source: https://github.com/phadej/cabal-fmt
Description: The cabal-fmt
formatter for cabal
files. By default, searches the current directory for *.cabal
files. Otherwise the search directory can be specified with --dir DIR
.
Usage: cabal-fmt [--dir PATH] <args>
.
Examples:
# runs the formatter on *.cabal files in the current directory
nix run github:tbidne/nix-hs-tools#cabal-fmt
# runs the formatter on *.cabal files in ../foo, and passes the --check flag
nix run github:tbidne/nix-hs-tools#cabal-fmt -- --dir ../foo --check
Source: https://github.com/fourmolu/fourmolu
Description: The fourmolu
code formatter for haskell source files. Runs fourmolu
recursively on all hs
files in the specified directory, ignoring dist-newstyle
and .stack-work
. By default runs on the current directory, though it can be specified with --dir
.
Usage: fourmolu [--dir PATH] <args>
.
Examples:
# fails if any files in the current (recursive) path are not formatted.
nix run github:tbidne/nix-hs-tools#fourmolu -- --mode check
# formats all files in some-dir
nix run github:tbidne/nix-hs-tools#fourmolu -- --dir ../some-dir --mode inplace
# specifies extensions manually; does not use cabal file's default-extensions
nix run github:tbidne/nix-hs-tools#fourmolu -- --no-cabal --ghc-opt -XImportQualifiedPost --ghc-opt -XTypeApplications
Source: https://github.com/tweag/ormolu
Description: The ormolu
code formatter for haskell source files. Runs ormolu
recursively on all hs
files in the specified directory, ignoring dist-newstyle
and .stack-work
. By default runs on the current directory, though it can be specified with --dir
.
Usage: ormolu [--dir PATH] <args>
.
Examples:
# fails if any files in the current (recursive) path are not formatted.
nix run github:tbidne/nix-hs-tools#ormolu -- --mode check
# formats all files in some-dir
nix run github:tbidne/nix-hs-tools#ormolu -- --dir ../some-dir --mode inplace
# specifies extensions manually; does not use cabal file's default-extensions
nix run github:tbidne/nix-hs-tools#ormolu -- --no-cabal --ghc-opt -XImportQualifiedPost --ghc-opt -XTypeApplications
Source: https://github.com/haskell/stylish-haskell
Description: The stylish-haskell
code formatter for haskell source files. Runs stylish-haskell
recursively on all hs
files in the specified directory, ignoring dist-newstyle
and .stack-work
. By default runs on the current directory, though it can be specified with --dir
.
Usage: stylish [--dir PATH] <args>
.
Examples:
# (recursively) formats all files in the current directory
nix run github:tbidne/nix-hs-tools#stylish -- --inplace
Source: https://github.com/ndmitchell/hlint
Description: The hlint
linter. Runs recursively on the current directory, though this can be overridden with --dir
. Ignores dist-newstyle
and stack-work
.
If the --refact
option is given, runs recursively on all haskell files with the --refactor
option and refactor flag -i
i.e. in-place. This behavior can be overridden by explicitly passing --refactor-options
.
Usage: hlint [--dir PATH] [--refact] <args>
.
Examples:
# recursively checks all files in the current directory
nix run github:tbidne/nix-hs-tools#hlint
# recursively applies suggestions to all files in the current directory, in-place.
nix run github:tbidne/nix-hs-tools#hlint -- --refact
# same as above but prompts before each change.
nix run github:tbidne/nix-hs-tools#hlint -- --refact --refactor-options="-is"
# not in-place and no prompt.
nix run github:tbidne/nix-hs-tools#hlint -- --refact --refactor-options=""
Source: https://github.com/haskell-hvr/cabal-plan/
Description: The cabal-plan
tool.
Usage: cabal-plan
.
Examples:
nix run github:tbidne/nix-hs-tools#cabal-plan
Source: https://github.com/Avi-D-coder/implicit-hie
Description: The gen-hie
tool for generating an hie
file. Redirects the output to hie.yaml
.
Usage: hie
.
Examples:
nix run github:tbidne/nix-hs-tools#hie
Source: https://github.com/NixOS/nixfmt
Description: The nixfmt
formatter. Recursively formats all *.nix
files in the current directory or --dir
.
Usage: nixfmt [--dir PATH] <args>
.
Examples:
nix run github:tbidne/nix-hs-tools#nixpkgs-fmt
Source: https://github.com/nix-community/nixpkgs-fmt
Description: The nixpkgs-fmt
formatter. Recursively formats all *.nix
files in the current directory or --dir
.
Usage: nixpkgs-fmt [--dir PATH] <args>
.
Examples:
nix run github:tbidne/nix-hs-tools#nixpkgs-fmt
Description: Returns a man page.
Usage: help
.
Description: Returns the version.
Usage: version
.