Last updated: 2019-04-14 15:59:37 +0100

Upstream URL: git clone


View repository

View issue tracker

Contents of README follows

Nix Lint

This package provides a linter for the Nix expression language (used by the Nix package manager and associated tools).


The main way to use this tool is to run the <code>nix-lint</code> executable. This will read Nix source code from standard input, write suggestions about the code to standard output in a simple JSON format, and write errors which prevented the linting from working (e.g. unparseable source code) to standard error. specifically <em>do not</em> supp

<code>nix-lint</code> will exit with code <code>0</code> if no errors were encountered and no suggestions were made; exit code <code>1</code> if errors prevented linting; or <code>2</code> if no errors were encountered and suggestions were made.

Control over linting (e.g. enabling/disabling certain checks) can be achieved by setting environment variables (TODO).

We expose all of our innards as a Haskell library, in case it's useful to anyone; for example, to write custom checking functions.


<code>nix-lint</code> specifically <em>does not</em> provide any of the following functionality, since the author feels it is either unneeded bloat, better performed by some other tool, or subjective enough that users may prefer to do it themselves (e.g. with a wrapper script):

<ul> <li>Command line arguments. We avoid these since they're unnecessarily complicated for both users and developers, for example: arbitrary ordering; grouping by order (e.g. <code>-foo myFoo</code>) or by formatting and parsing (e.g. <code>--foo=myFoo</code>); inheriting arguments is painful; myriad conventions and long/short redundancy; setting defaults requires an alias or wrapper; etc.</li> <li>Reading/writing files. This is better handled by the shell, editor, Web UI, build server, etc. that is invoking the linter.</li> <li>Looping through many files/expressions. Again, this is better handled by the invoking process (e.g. via <code>find</code>)</li> <li>Human-readable output. Our machine readable output is trivial to display in a variety of ways (plain text, ANSI terminal codes, email, HTML, etc.) so we leave that up to the user. The <code>jq</code> tool is nice for scripting.</li> </ul>


The following checks are supported. All checks are enabled by default; to disable a check add its ID to the <code>NIX_LINT_DISABLE</code> environment variable.