# Lint.nix: simple linting/formatting framework

**URL:** https://discourse.nixos.org/t/lint-nix-simple-linting-formatting-framework/27516
**Category:** Announcements
**Created:** [April 22, 2023, 3:37pm UTC](https://discourse.nixos.org/t/lint-nix-simple-linting-formatting-framework/27516 "2023-04-22T15:37:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jonascarpay](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jonascarpay/32/4620_2.png) [@jonascarpay](https://discourse.nixos.org/u/jonascarpay)
#### Post date: [April 22, 2023, 3:37pm UTC](https://discourse.nixos.org/t/lint-nix-simple-linting-formatting-framework/27516/1 "2023-04-22T15:37:25Z")

</div>

I’m happy to announce the open-sourcing of [`lint.nix`](https://github.com/xc-jp/lint.nix), a (very) simple formatting/linting framework that we’ve been using at work. There’s not much to it, but we’ve been very happy with it as a quick way of setting up linting and formatting on our projects.

---

<div class="post-metadata">

### Author: ![Sandro](https://discourse.nixos.org/user_avatar/discourse.nixos.org/sandro/32/2865_2.png) [@Sandro](https://discourse.nixos.org/u/Sandro)
#### Post date: [April 22, 2023, 8:40pm UTC](https://discourse.nixos.org/t/lint-nix-simple-linting-formatting-framework/27516/2 "2023-04-22T20:40:08Z")

</div>

You know [GitHub - numtide/treefmt-nix: treefmt nix configuration](https://github.com/numtide/treefmt-nix) ?

---

<div class="post-metadata">

### Author: ![jonascarpay](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jonascarpay/32/4620_2.png) [@jonascarpay](https://discourse.nixos.org/u/jonascarpay)
#### Post date: [April 23, 2023, 2:27am UTC](https://discourse.nixos.org/t/lint-nix-simple-linting-formatting-framework/27516/3 "2023-04-23T02:27:42Z")

</div>

I do. I haven’t actually used it (it didn’t exist yet when we wrote the initial version of lint.nix 3+ years ago) so I can’t speak from experience or tell you in what cases you should pick one or the other, but they obviously sit at very different points in the design space.

Lint.nix is a little over 100 loc, and obviously Nix-only. It manages to do a lot with a little, but it’s also not really competing in terms of scope or features.

---

<div class="post-metadata">

### Author: ![blaggacao](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@blaggacao](https://discourse.nixos.org/u/blaggacao)
#### Post date: [April 23, 2023, 4:15pm UTC](https://discourse.nixos.org/t/lint-nix-simple-linting-formatting-framework/27516/4 "2023-04-23T16:15:39Z")

</div>

One issue I’ve been having with any nix based approach is Time-To-First-Feedback in CI.

People expect this for formatters and linters to be in the seconds range, but with non-optimized nix-based approaches more often than not [in bigger projects] Nix evaluation commonly gets in the way of scoring on that metric.

As to my knowledge, there’s no optimized solution available which would include:

- Don’t pin anything, defer to whatever is already in CI cache
- Always use static builds to reduce setup time

* * *

If we’re lucky, tackling these UX problems may be the next iteration in this space of Nix tooling.

EDIT: Maybe `self.formatter` goes some way to mitigate this. I wouldn’t know, I’ve been working with full-blow local environments, so far, which easily can happen to have a side effect that screws up set up time.

---

<div class="post-metadata">

### Author: ![bobvanderlinden](https://discourse.nixos.org/user_avatar/discourse.nixos.org/bobvanderlinden/32/59_2.png) [@bobvanderlinden](https://discourse.nixos.org/u/bobvanderlinden)
#### Post date: [April 23, 2023, 6:18pm UTC](https://discourse.nixos.org/t/lint-nix-simple-linting-formatting-framework/27516/5 "2023-04-23T18:18:16Z")

</div>

When using something like treefmt inside devenv or nix develop you’d only need to evaluate and download once when entering a project. After that it’s just as fast as usual to run the formatters.

For CI it does depend a bit on the method of caching that the CI uses.

---

<div class="post-metadata">

### Author: ![blaggacao](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@blaggacao](https://discourse.nixos.org/u/blaggacao)
#### Post date: [April 25, 2023, 5:46am UTC](https://discourse.nixos.org/t/lint-nix-simple-linting-formatting-framework/27516/6 "2023-04-25T05:46:03Z")

</div>

> [@bobvanderlinden](#):
>
> For CI it does depend a bit on the method of caching that the CI uses.

Smart caching is absolutely part of the solution package. In fact, I wouldn’t rule out persistent eval caching for it’s significant upside, especially when dealing with gnarly IFD.

I may one day try something along the lines of:

- Have a custom CI image
- Have that image pin nixpkgs (or for that matter provide any relevant inputs via a built-in predefined registry)
- Have that image ship a usable eval cache
- Run X in CI via `nix run --override-inputs ...` making use of the image-wise pinning

As a Nix power-user, I may be comfortable in setting up and maintaining such a design and setup.

As a layman interested in leveraging Nix technologies, my current thinking is that an ecosystem tool such as `treefmt` could optionally handle command resolution in the presence of a detected `nix` command via heuristics.
