Skip to content

feat(nix): add statix linting and fix all lint errors - #1222

Merged
shunkakinoki merged 2 commits into
mainfrom
bridge-cse_013QLpsFWtZvYuBS3J5HLQWa
Mar 20, 2026
Merged

feat(nix): add statix linting and fix all lint errors#1222
shunkakinoki merged 2 commits into
mainfrom
bridge-cse_013QLpsFWtZvYuBS3J5HLQWa

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add statix nix linter integration with make nix-lint target and statix.toml config (W20 repeated_keys disabled as it's idiomatic in NixOS/home-manager)
  • Fix all statix lint errors across 20 nix files: use inherit instead of manual assignment (W03/W04), remove unnecessary boolean comparisons (W01), remove useless parentheses (W08), replace empty patterns with _ (W10)
  • Add nix-lint GitHub Actions job to the Nix workflow with gate check

Test plan

  • nix run nixpkgs#statix -- check . passes clean (exit 0)
  • nix-lint CI job passes on PR

🤖 Generated with Claude Code


Summary by cubic

Adds statix linting with a make nix-lint target and a CI job, fixes all Nix lint issues, and applies the project formatter. This enforces consistent Nix style and adds a gate to prevent regressions.

  • New Features

    • Added make nix-lint (runs nixpkgs#statix) and included it in make check.
    • Added nix-lint job to .github/workflows/nix.yml and included it in the workflow gate.
    • Introduced statix.toml (disables repeated_keys, sets nix_version, ignores .direnv).
  • Refactors

    • Applied repository-wide Nix formatting.
    • Resolved all statix findings: use inherit/inherit (scope), simplify booleans, remove extra parens, use _: for unused args, and replace empty patterns with _.
    • No functional changes intended.

Written for commit ddd8af5. Summary will update on new commits.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 20, 2026 01:18
@mesa-dot-dev

mesa-dot-dev Bot commented Mar 20, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b88a1ca3-f53a-44f6-ba71-4d52880d43a3

📥 Commits

Reviewing files that changed from the base of the PR and between f01440c and ddd8af5.

📒 Files selected for processing (6)
  • config/keyd/default.nix
  • config/rofi/default.nix
  • config/tmuxinator/default.nix
  • home-manager/services/docker/default.nix
  • hosts/darwin/default.nix
  • overlays/default.nix
✅ Files skipped from review due to trivial changes (6)
  • config/keyd/default.nix
  • config/rofi/default.nix
  • config/tmuxinator/default.nix
  • hosts/darwin/default.nix
  • overlays/default.nix
  • home-manager/services/docker/default.nix

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Added Nix linting to CI and local build targets (statix).
    • Added statix configuration for lint rules and Nix compatibility.
    • Standardized Nix expression bindings and module parameter patterns across configs for consistency.
    • Adjusted tests to be more permissive about a specific package attribute.

Walkthrough

Added a GitHub Actions job nix-lint, a Makefile nix-lint target, a statix.toml config, and performed widespread Nix expression refactors to use inherit and simplified module parameter patterns across many Nix files.

Changes

Cohort / File(s) Summary
CI & Linting
​.github/workflows/nix.yml, Makefile, statix.toml
New nix-lint GitHub Actions job; Makefile gains nix-lint target and is invoked from check; added statix.toml configuration.
Module Parameter Simplification
config/keyd/default.nix, config/rofi/default.nix, config/tmuxinator/default.nix, hosts/darwin/default.nix
Replaced destructured module arguments ({ ... }:) with anonymous wildcard (_:) in several module exports.
Template substitution inherit refactor
devenv.nix, home-manager/services/cliproxyapi/default.nix, home-manager/services/docker-postgres/default.nix, home-manager/services/docker/default.nix, named-hosts/matic/falcon.nix, home-manager/modules/yek/default.nix
Rewrote pkgs.replaceVars bindings from explicit name = pkgs.foo; to inherit (pkgs) foo; (and similar) for template variable wiring.
General inherit / binding modernizations
home-manager/modules/cargo-globals/default.nix, home-manager/programs/fish/default.nix, hosts/linux/default.nix, hosts/nixos/default.nix, named-hosts/galactica/default.nix, named-hosts/kyber/default.nix, named-hosts/matic/default.nix, overlays/default.nix
Systematic replacement of explicit local bindings with inherit forms for lib, pkgs, system, pkgs.* attributes, and similar attribute projection adjustments.
Small logic/format tweaks & tests
home-manager/modules/openclaw/default.nix, tests/lib.nix
Removed redundant parentheses in a lib.mkIf condition; relaxed tests/lib.nix check to treat allowUnfree as truthy if present.
Minor fish plugin src refactor
home-manager/programs/fish/default.nix
Changed plugin src references to use inherit (pkgs.fishPlugins.<name>) src form.

Sequence Diagram(s)

sequenceDiagram
  participant GH as "GitHub Actions"
  participant Repo as "Repository"
  participant Runner as "ubuntu-latest runner"
  participant Nix as "Nix / statix"
  participant Make as "Makefile"

  GH->>Repo: workflow triggered (nix)
  GH->>Runner: start job `nix-lint`
  Runner->>Repo: actions/checkout
  Runner->>Nix: install Nix (cachix/install-nix-action)
  Runner->>Make: run `make nix-lint`
  Make->>Nix: execute `nix run nixpkgs#statix -- check .`
  Nix-->>Make: statix results
  Make-->>Runner: exit status
  Runner-->>GH: job complete (success/failure)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 I hopped through Nix with statix in paw,
Swapped = for inherit—oh what a law!
Wildcards hide params, neat and spry,
CI hums checks as linters fly.
A joyful nibble, commit complete—hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(nix): add statix linting and fix all lint errors' clearly and concisely summarizes the main changes: introducing statix linting integration and applying lint fixes across the codebase.
Description check ✅ Passed The description comprehensively explains the changes including statix integration, configuration details, the types of lint errors fixed, CI setup, and test plan. It is directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bridge-cse_013QLpsFWtZvYuBS3J5HLQWa
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Mar 20, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Added statix Nix linter integration with a make nix-lint target and a GitHub Actions job, along with fixing all identified lint errors across the codebase.

What changed?

  • Nix Linting Integration:
    • Added make nix-lint target to Makefile which runs statix, and integrated it into the make check process.
    • Added a nix-lint GitHub Actions job to .github/workflows/nix.yml, making nix-test dependent on its successful completion.
    • Introduced statix.toml to configure statix, disabling repeated_keys, setting nix_version="2.4", and ignoring .direnv.
  • Nix Code Refactoring for Lint Compliance:
    • inherit keyword usage: Replaced explicit variable assignments with the more concise inherit keyword across numerous files including devenv.nix, home-manager/modules/cargo-globals/default.nix, home-manager/modules/yek/default.nix, home-manager/programs/fish/default.nix, home-manager/services/cliproxyapi/default.nix, home-manager/services/docker-postgres/default.nix, home-manager/services/docker/default.nix, hosts/darwin/default.nix, hosts/linux/default.nix, hosts/nixos/default.nix, named-hosts/galactica/default.nix, named-hosts/kyber/default.nix, named-hosts/matic/default.nix, named-hosts/matic/falcon.nix, and overlays/default.nix.
    • Unused argument simplification: Updated function signatures to use _ for unused arguments instead of destructured objects in config/keyd/default.nix, config/rofi/default.nix, config/tmuxinator/default.nix, and hosts/darwin/default.nix.
    • Boolean expression simplification: Removed redundant parentheses around boolean expressions in home-manager/modules/openclaw/default.nix and removed an explicit == true check in tests/lib.nix.

Description generated by Mesa. Update settings

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 23 files

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces statix linting to the nix environment, fixes existing lint errors, and integrates linting into the CI pipeline. The goal is to improve code quality and consistency across nix files by automating the linting process and enforcing coding standards.

Highlights

  • Statix Linting Integration: Added statix to the nix development environment, including a make nix-lint target and statix.toml configuration.
  • Lint Error Fixes: Resolved all statix lint errors across 20 nix files, addressing issues like manual assignment replacements with inherit, unnecessary boolean comparisons, and useless parentheses.
  • GitHub Actions Integration: Integrated a nix-lint job into the Nix workflow within GitHub Actions, implementing a gate check to ensure code quality.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/nix.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/lib.nix (1)

64-64: Subtle semantic change in test assertion.

The original == true strictly asserted the value is the boolean true. The new truthy check would also pass for other truthy values (e.g., a non-empty string or number). Given that lib/nixpkgs-config.nix hardcodes allowUnfree = true, this is acceptable, but note that the test now validates "exists and is truthy" rather than "is exactly true".

If strict boolean validation is desired, consider using builtins.isBool like the other tests in this file:

if nixpkgsConfig ? allowUnfree && builtins.isBool nixpkgsConfig.allowUnfree && nixpkgsConfig.allowUnfree then
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/lib.nix` at line 64, The test currently checks if nixpkgsConfig ?
allowUnfree && nixpkgsConfig.allowUnfree which accepts any truthy value; change
the condition to require a strict boolean by adding a builtins.isBool check for
nixpkgsConfig.allowUnfree (i.e., ensure
builtins.isBool(nixpkgsConfig.allowUnfree) && nixpkgsConfig.allowUnfree) so the
test only passes when allowUnfree is exactly true; update the conditional in
tests/lib.nix accordingly referencing nixpkgsConfig and allowUnfree.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/lib.nix`:
- Line 64: The test currently checks if nixpkgsConfig ? allowUnfree &&
nixpkgsConfig.allowUnfree which accepts any truthy value; change the condition
to require a strict boolean by adding a builtins.isBool check for
nixpkgsConfig.allowUnfree (i.e., ensure
builtins.isBool(nixpkgsConfig.allowUnfree) && nixpkgsConfig.allowUnfree) so the
test only passes when allowUnfree is exactly true; update the conditional in
tests/lib.nix accordingly referencing nixpkgsConfig and allowUnfree.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d75d843-e1b2-4372-abcf-d9627df1720e

📥 Commits

Reviewing files that changed from the base of the PR and between a9bdd1d and f01440c.

📒 Files selected for processing (23)
  • .github/workflows/nix.yml
  • Makefile
  • config/keyd/default.nix
  • config/rofi/default.nix
  • config/tmuxinator/default.nix
  • devenv.nix
  • home-manager/modules/cargo-globals/default.nix
  • home-manager/modules/openclaw/default.nix
  • home-manager/modules/yek/default.nix
  • home-manager/programs/fish/default.nix
  • home-manager/services/cliproxyapi/default.nix
  • home-manager/services/docker-postgres/default.nix
  • home-manager/services/docker/default.nix
  • hosts/darwin/default.nix
  • hosts/linux/default.nix
  • hosts/nixos/default.nix
  • named-hosts/galactica/default.nix
  • named-hosts/kyber/default.nix
  • named-hosts/matic/default.nix
  • named-hosts/matic/falcon.nix
  • overlays/default.nix
  • statix.toml
  • tests/lib.nix

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR integrates statix linting into the repo’s Nix workflow (local make + CI) and applies repo-wide Nix refactors to satisfy the new linter rules.

Changes:

  • Add statix.toml configuration and a make nix-lint target, and wire it into make check.
  • Add a nix-lint job to the GitHub Actions Nix workflow and gate it via the existing “alls-green” check.
  • Apply statix-driven cleanups across multiple Nix files (e.g., inherit, boolean simplifications, unused arg patterns).

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/lib.nix Simplifies allowUnfree boolean check per statix guidance.
statix.toml Adds statix configuration (disable repeated_keys, set version, ignore .direnv).
overlays/default.nix Refactors attribute assignments to inherit for statix compliance.
named-hosts/matic/falcon.nix Uses inherit in replaceVars substitutions.
named-hosts/matic/default.nix Refactors args/secrets mapping to use inherit.
named-hosts/kyber/default.nix Uses inherit for lib, username, and secrets mapping.
named-hosts/galactica/default.nix Uses inherit for specialArgs and secrets mapping.
hosts/nixos/default.nix Uses inherit for lib and pkgs when passing args to HM.
hosts/linux/default.nix Uses inherit for lib and username.
hosts/darwin/default.nix Replaces unused module arg pattern with _: and uses inherit for lib.
home-manager/services/docker/default.nix Uses inherit in replaceVars substitutions.
home-manager/services/docker-postgres/default.nix Uses inherit in replaceVars substitutions.
home-manager/services/cliproxyapi/default.nix Uses inherit in replaceVars substitutions.
home-manager/programs/fish/default.nix Refactors fish plugin src fields to use inherit.
home-manager/modules/yek/default.nix Uses inherit in replaceVars substitutions.
home-manager/modules/openclaw/default.nix Removes unnecessary parentheses in mkIf.
home-manager/modules/cargo-globals/default.nix Uses inherit for isDarwin.
devenv.nix Uses inherit in replaceVars substitutions (fishtape wrapper).
config/tmuxinator/default.nix Replaces unused arg pattern with _:.
config/rofi/default.nix Replaces unused arg pattern with _:.
config/keyd/default.nix Replaces unused arg pattern with _:.
Makefile Adds nix-lint target and runs it as part of check.
.github/workflows/nix.yml Adds nix-lint CI job and includes it in the overall Nix workflow gate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile
.PHONY: nix-lint
nix-lint: ## Lint Nix files with statix.
@echo "🔍 Linting Nix files with statix..."
@$(NIX_EXEC) run nixpkgs#statix -- check .

Copilot AI Mar 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix-lint runs nix run nixpkgs#statix without $(NIX_FLAGS). Other Nix commands in this Makefile pass $(NIX_FLAGS) to ensure flakes/nix-command are enabled and cache options apply; without it, make nix-lint can fail on machines where those features aren’t enabled globally. Pass $(NIX_FLAGS) (and keep the invocation consistent with the other nix run targets).

Suggested change
@$(NIX_EXEC) run nixpkgs#statix -- check .
@$(NIX_EXEC) run $(NIX_FLAGS) nixpkgs#statix -- check .

Copilot uses AI. Check for mistakes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great improvement, adding statix linting and fixing all associated issues across the codebase. The Nix code is now more consistent and idiomatic. I've added a few minor suggestions to further enhance conciseness and consistency in a couple of files, in line with the goals of this PR.

builtins.readFile (
pkgs.replaceVars ./scripts/docker-start.sh {
bash = pkgs.bash;
inherit (pkgs) bash;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For conciseness, you can combine this inherit with the one for docker on line 38. I've added a suggestion on line 38 to remove the now-redundant line.

        inherit (pkgs) bash docker;

inherit (pkgs) bash;
start_script = startScript;
docker = pkgs.docker;
inherit (pkgs) docker;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line is now redundant and can be removed, as it has been combined into the inherit statement on line 36.

builtins.readFile (
pkgs.replaceVars ./start-postgres-wrapper.sh {
bash = pkgs.bash;
inherit (pkgs) bash;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For conciseness, you can combine this inherit with the one for docker on line 14. I've added a suggestion on line 14 to remove the now-redundant line.

        inherit (pkgs) bash docker;

inherit (pkgs) bash;
start_script = startScript;
docker = pkgs.docker;
inherit (pkgs) docker;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line is now redundant and can be removed, as it has been combined into the inherit statement on line 12.

Comment thread hosts/nixos/default.nix
Comment on lines +128 to +129
inherit (nixpkgs) lib;
inherit pkgs;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve consistency with other parts of your configuration, you can inherit pkgs first and then lib from pkgs. Since pkgs is derived from nixpkgs, pkgs.lib is equivalent to nixpkgs.lib here.

        inherit pkgs;
        inherit (pkgs) lib;

Comment on lines +396 to +397
inherit (inputs.nixpkgs) lib;
inherit pkgs;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve consistency, consider inheriting pkgs first, and then lib from pkgs. Since pkgs is derived from inputs.nixpkgs, this is functionally equivalent and slightly more idiomatic.

              inherit pkgs;
              inherit (pkgs) lib;

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shunkakinoki
shunkakinoki merged commit 1ff38b7 into main Mar 20, 2026
38 checks passed
@shunkakinoki
shunkakinoki deleted the bridge-cse_013QLpsFWtZvYuBS3J5HLQWa branch March 20, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants