Skip to content

Commit

Permalink
chore(nix): use nixfmt instead of nixpkgs-fmt
Browse files Browse the repository at this point in the history
- It won't complain if there is no nix on your machine
  (but then why would you touch nix files?)
- It'll run only for changed files

The code style is changed to match with RFC-166[^1]

[^1]: NixOS/rfcs#166
  • Loading branch information
vlaci committed Oct 10, 2024
1 parent ffd590d commit 0afe1f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
- name: Setup 3rd party dependencies
uses: ./.github/actions/setup-dependencies

- name: Setup Nix
uses: cachix/install-nix-action@v30
with:
install_url: https://releases.nixos.org/nix/nix-2.18.8/install

- name: Check pre-commit hook
uses: pre-commit/action@v3.0.1

Expand Down
16 changes: 11 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,24 @@ repos:
types_or: [python, pyi]
require_serial: true
entry: poetry run ruff format --force-exclude
- id: nixfmt
name: Format Nix (nixfmt)
types: [nix]
language: system
require_serial: true
entry: bash -c 'command -v nix && nix "$@" || echo "skipping nixfmt"' nix
args:
- --experimental-features
- nix-command flakes
- --accept-flake-config
- fmt

- repo: https://github.com/jendrikseipp/vulture
rev: v2.7
hooks:
- id: vulture
name: Check vulture

- repo: https://github.com/nix-community/nixpkgs-fmt
rev: v1.3.0
hooks:
- id: nixpkgs-fmt

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.21.0
hooks:
Expand Down
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,7 @@
});

legacyPackages = forAllSystems (system: nixpkgsFor.${system});

formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
};
}

0 comments on commit 0afe1f7

Please sign in to comment.