Skip to content

Commit

Permalink
Add CI and pre-commit hooks for nix files
Browse files Browse the repository at this point in the history
  • Loading branch information
mweinelt committed Feb 14, 2024
1 parent cf01b1a commit 1fb9cb9
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use_flake
16 changes: 16 additions & 0 deletions .github/workflows/flake-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Lint"

on:
push:
pull_request:

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- run: |
nix flake check -L
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@

# Nix build outputs
result

# pre-commit
.pre-commit-config.yaml
171 changes: 171 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
description = "NixOS Infra";

inputs = {
nixpkgs.url = "github:NIxOS/nixpkgs";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, pre-commit-hooks, flake-utils }:
flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] (system: {
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
deadnix.enable = true;
statix.enable = true;
};
};
};
devShells.default = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
}
);
}

0 comments on commit 1fb9cb9

Please sign in to comment.