ShellCheck inline scripts during test phase

I’m sure there are wild examples of this as well, but if nothing else writeShellApplication was added to nixpkgs in the interim:


FWIW, I’ve come to see lint/format checks in the check/installCheck phases as a minor antipattern. Unlike a normal test suite that’s developing with your codebase, version bumps of these tools in nixpkgs can cause scripts to stop ~building even when their source is unchanged.

This can be easy enough to cope with if they’re only in your local config, but it can be a chore if they aren’t (i.e., they’re in nixpkgs, third-party code, or even your own code that you’ve extracted into a separate project/flake for others to depend on).

I think it’s ideal if you can run these checks as part of your development process and not otherwise. If the inline scripts are their own package/derivation (as with writeScriptBin) I’d probably just check these from another derivation that depends on them. If I had to put one in a package’s check/test phases, I’d probably guard it behind an argument that defaults to false and have my own process for building the package with it set to true.

5 Likes