Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: add linters and formatters #236

Closed
2 of 8 tasks
trueNAHO opened this issue Jan 31, 2024 · 2 comments · Fixed by #519
Closed
2 of 8 tasks

treewide: add linters and formatters #236

trueNAHO opened this issue Jan 31, 2024 · 2 comments · Fixed by #519
Labels
C-tracking-issue Category: A tracking issue chore Project maintenance task technical debt Things which should be cleaned up or improved

Comments

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 31, 2024

About

This is a tracking issue for integrating linters and formatters.

Steps

Unresolved Questions

@danth danth changed the title ci(flake): add linter ci: add linter Apr 22, 2024
@danth danth added the chore Project maintenance task label Apr 22, 2024
@trueNAHO trueNAHO changed the title ci: add linter treewide: add linters and formatters Jun 16, 2024
@trueNAHO trueNAHO added technical debt Things which should be cleaned up or improved C-tracking-issue Category: A tracking issue labels Jun 16, 2024
@LovingMelody
Copy link

LovingMelody commented Jul 21, 2024

 treewide: integrate linters and formatters into nix develop

What is the reasoning for this to be integrated into nix develop instead of just using nix fmt?

treewide: integrate linters and formatters into nix flake check

ci: integrate linters and formatters into GitHub Actions

Maybe treefmt-nix would be a good solution?
The config could look something like..

_: {
  # Project root
  projectRootFile = "flake.nix";
  programs = {
    nixfmt.enable = true;
    deadnix = {
      enable = true;
      # Can break callPackage if this is set to false
      no-lambda-pattern-names = true;
    };
    statix.enable = true;
  };
}
``

@trueNAHO
Copy link
Collaborator Author

trueNAHO commented Jul 21, 2024

 treewide: integrate linters and formatters into nix develop

What is the reasoning for this to be integrated into nix develop instead of just using nix fmt?

nix develop and nix flake simplify CI integration:

I added nix fmt to the Steps of this tracking issue.

treewide: integrate linters and formatters into nix flake check
ci: integrate linters and formatters into GitHub Actions

Maybe treefmt-nix would be a good solution? The config could look something like..

_: {
  # Project root
  projectRootFile = "flake.nix";
  programs = {
    nixfmt.enable = true;
    deadnix = {
      enable = true;
      # Can break callPackage if this is set to false
      no-lambda-pattern-names = true;
    };
    statix.enable = true;
  };
}
``

Choosing the formatter is somewhat controversial. IIRC, nixfmt tries to touch as few lines as possible to reduce merge conflicts in Nixpkgs, which is one of the most active GitHub repositories. However, since Stylix is nowhere near as active as Nixpkgs we can choose a more beautiful formatter, touching more lines.

For example, alejandra is my favourite Nix formatter:

For reference, I use git-hooks.nix to set up the following linter and formatter hooks in my dotfiles repository:

-- #426 (comment)

I would resolve this issue by first refactoring the GitHub Action to run a single nix command, and then replacing that nix command's implementation with a pre-commit hook.

trueNAHO added a commit to trueNAHO/stylix that referenced this issue Aug 22, 2024
This change was generated with 'nix fmt'.

Closes: danth#236
Link: danth#519
trueNAHO added a commit that referenced this issue Jan 4, 2025
…ows (#519)

Add developer shells with direnv integration and the deadnix, hlint,
nixfmt-rfc-style, statix, stylish-haskell, typos, and yamllint
pre-commit hooks.

Ensure 'nix flake check' works as expected and add the nix-flake-check
package, which is a parallelized alternative to 'nix flake check'.

Improve and update the GitHub workflows.

Closes: #236
Link: #519

Approved-by: Daniel Thwaites <[email protected]>
trueNAHO added a commit that referenced this issue Jan 4, 2025
…ows (#746)

Add developer shells with direnv integration and the deadnix, hlint,
nixfmt-rfc-style, statix, stylish-haskell, typos, and yamllint
pre-commit hooks.

Ensure 'nix flake check' works as expected and add the nix-flake-check
package, which is a parallelized alternative to 'nix flake check'.

Improve and update the GitHub workflows.

Closes: #236
Link: #519

Approved-by: Daniel Thwaites <[email protected]>
(adapted from commit 7dfcdb4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue chore Project maintenance task technical debt Things which should be cleaned up or improved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants