feat: implement ruff as flake checks

Had to add `--impure` to the call due to the following error otherwise:

```
error:
       … while checking flake output 'packages'
         at /nix/store/5cjz7jyqyfr5vq8b6bjs24vdnvdhy9rb-source/flake.nix:118:7:
          117|
          118|       packages = forEachSystem (system:
             |       ^
          119|         let

       … while checking the derivation 'packages.x86_64-linux.bootstrap-aarch64'
         at /nix/store/dg3hg3ksr5sl3adskxiwj7357z47ggvr-source/lib/attrsets.nix:977:47:
          976|   */
          977|   nameValuePair = name: value: { inherit name value; };
             |                                               ^
          978|

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: 'builtins.storePath' is not allowed in pure evaluation mode

```
This commit is contained in:
Philippe Laflamme 2025-07-11 14:52:52 -04:00
parent bd677b46e6
commit 505cc019ae
No known key found for this signature in database
GPG key ID: 08BC443CD10E4DC4
4 changed files with 33 additions and 22 deletions

View file

@ -5,7 +5,7 @@ on:
schedule:
- cron: 0 0 * * 1
jobs:
lint-nix:
check:
runs-on: ubuntu-latest
steps:
@ -15,21 +15,5 @@ jobs:
- name: Install nix
uses: cachix/install-nix-action@v25
- name: Run nix-formatter-pack-check
run: nix build .#checks.x86_64-linux.nix-formatter-pack-check
lint-py:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install nix
uses: cachix/install-nix-action@v25
- name: Run ruff linter
run: nix run 'nixpkgs#ruff' -- check
- name: Run ruff formatter
run: nix run 'nixpkgs#ruff' -- format --diff
- name: Run flake checks
run: nix flake check --impure -L

10
checks/ruff-fmt.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs, checkRoot }:
pkgs.runCommandLocal "ruff-fmt"
{
src = ./.;
nativeBuildInputs = with pkgs; [ ruff ];
}
''
cd ${checkRoot};
ruff format --no-cache --diff && mkdir $out
''

10
checks/ruff-lint.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs, checkRoot }:
pkgs.runCommandLocal "ruff-lint"
{
src = ./.;
nativeBuildInputs = with pkgs; [ ruff ];
}
''
cd ${checkRoot};
ruff check --no-cache && mkdir $out
''

View file

@ -63,9 +63,16 @@
};
});
checks = forEachSystem (system: {
checks = forEachSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
nix-formatter-pack-check = nix-formatter-pack.lib.mkCheck formatterPackArgsFor.${system};
});
ruff-lint = import ./checks/ruff-lint.nix { inherit pkgs; checkRoot = ./.; };
ruff-fmt = import ./checks/ruff-fmt.nix { inherit pkgs; checkRoot = ./.; };
}
);
formatter = forEachSystem (system: nix-formatter-pack.lib.mkFormatter formatterPackArgsFor.${system});