Closed aij closed 3 years ago
If we want to keep the code regular, this would be an additional exception to the rule-set.
I think the best option is to re-structure the nix code to make it more readable. Eg:
let
my_fn = { pkgs, lib, ... }:
let
foo = 42;
bar = 57;
in
{
baz = qux;
};
in
import ./make-test-python.nix my_fn
Restructuring the code like that is not a good workaround to avoid the extra indentation. It would indent the whole file two extra levels instead of just one.
I'm not sure what the more general rule should be exactly, but it probably shouldn't be based on the number of lines.
FWIW, this pattern is not exactly uncommon in nixpkgs. Here's a few more examples (a few do indent the main expression):
@aij I update your comment for better views by adding <details></details>
. You can't remove if you don't like it, but I hope you don't mind.
For your concern, it's fair and we should think about it.
I tried using
nixpkgs-fmt
on a test I was working on and it indented everything except for the first line an extra level, which seemed kind of ridiculous in the case ofnixos/tests/ceph-*.nix
. Below is a smaller example showing the same behavior, though to a much smaller extent since there are fewer lines for it to indent.Input
Output
Desired output