Skip to content

Commit 1b90df5

Browse files
committed
config(*.nix): Configure pre-commit to be used in the repo
1 parent c77b04e commit 1b90df5

File tree

4 files changed

+68
-6
lines changed

4 files changed

+68
-6
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "Lint"
2+
3+
on:
4+
# Allow this workflow to be reused by other workflows:
5+
workflow_call:
6+
inputs:
7+
runner:
8+
description: 'JSON-encoded list of runner labels'
9+
default: '["self-hosted"]'
10+
required: false
11+
type: string
12+
13+
secrets:
14+
NIX_GITHUB_TOKEN:
15+
description: GitHub token to add as access-token in nix.conf
16+
required: false
17+
CACHIX_AUTH_TOKEN:
18+
description: 'Cachix auth token'
19+
required: true
20+
21+
jobs:
22+
lint:
23+
runs-on: self-hosted
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Install Nix
28+
uses: metacraft-labs/nixos-modules/.github/install-nix@main
29+
with:
30+
nix-github-token: ${{ secrets.NIX_GITHUB_TOKEN }}
31+
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
32+
cachix-cache: ${{ vars.CACHIX_CACHE }}
33+
trusted-public-keys: ${{ vars.TRUSTED_PUBLIC_KEYS }}
34+
substituters: ${{ vars.SUBSTITUTERS }}
35+
36+
- uses: cachix/cachix-action@v15
37+
with:
38+
name: ${{ vars.CACHIX_CACHE }}
39+
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
40+
41+
- name: Build & activate the Nix Dev Shell
42+
run: |
43+
eval "$(nix print-dev-env --accept-flake-config --accept-flake-config --impure .#devShells.x86_64-linux.default || echo exit 1)"
44+
env >> "$GITHUB_ENV"
45+
46+
- name: Check formatting
47+
run: pre-commit run --all
48+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ matrix-*.json
1313
shardMatrix.json
1414

1515
.vscode
16+
17+
# Pre Commit
18+
.pre-commit-config.yaml

flake.nix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,22 @@
246246
system,
247247
pkgs,
248248
inputs',
249+
self',
249250
...
250251
}:
251252
{
252253
_module.args.pkgs = import nixpkgs {
253254
inherit system;
254255
config.allowUnfree = true;
255256
};
256-
devShells.default = import ./shells/default.nix { inherit pkgs flake inputs'; };
257+
devShells.default = import ./shells/default.nix {
258+
inherit
259+
pkgs
260+
flake
261+
inputs'
262+
self'
263+
;
264+
};
257265
devShells.ci = import ./shells/ci.nix { inherit pkgs; };
258266
};
259267
flake.lib.create =

shells/default.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
self',
23
pkgs,
3-
flake,
44
inputs',
55
...
66
}:
@@ -27,10 +27,13 @@ pkgs.mkShell {
2727
inputs'.dlang-nix.packages.dmd
2828
inputs'.dlang-nix.packages.dub
2929
act
30+
self'.checks.pre-commit-check.enabledPackages
3031
];
3132

32-
shellHook = ''
33-
export REPO_ROOT="$PWD"
34-
figlet -t "${flake.description}"
35-
'';
33+
shellHook =
34+
''
35+
export REPO_ROOT="$PWD"
36+
figlet -t "Metacraft Nixos Modules"
37+
''
38+
+ self'.checks.pre-commit-check.shellHook;
3639
}

0 commit comments

Comments
 (0)