Skip to content

Commit

Permalink
add a nix fmt/flake check action
Browse files Browse the repository at this point in the history
  • Loading branch information
dougch committed Feb 12, 2025
1 parent f9031aa commit 968f9ee
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: "Nix checks"
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
nixflake:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v29
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix build
- run: nix flake check
nixfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v29
- name: nix fmt
run: nix fmt $(find . -name \*nix -type f -not -path "./.git/*")
- name: Changed files
id: dirty
run: |
echo "Checking nix files with: nix fmt ..."
git diff --exit-code
continue-on-error: true
- name: Failure case
if: steps.dirty.outcome != 'success'
run: |
echo "Please fix formatting with nix fmt (file)"
exit 1
- name: Success
run: echo "All nix files passed format check"
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
src = self;
name = "aws-lc";
inherit system;
nativeBuildInputs = [ pkgs.ninja pkgs.cmake pkgs.perl pkgs.golang ];
nativeBuildInputs = [ pkgs.ninja pkgs.cmake pkgs.perl pkgs.go ];
cmakeFlags = [
"-GNinja"
"-DBUILD_SHARED_LIBS=ON"
Expand Down
6 changes: 3 additions & 3 deletions nix/devshell.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{pkgs}:
{ pkgs }:
pkgs.mkShell rec {
buildInputs = [ pkgs.cmake ];
packages = [ pkgs.gdb pkgs.nixfmt pkgs.ninja pkgs.cmake pkgs.perl pkgs.go ];
packages = [ pkgs.nixfmt-classic pkgs.ninja pkgs.cmake pkgs.perl pkgs.go ];
shellHook = ''
echo "Entering a devShell..."
export PS1="[awslc nix] $PS1"
Expand All @@ -20,5 +20,5 @@ pkgs.mkShell rec {
function unit {
ninja -C build run_tests
}
'';
'';
}

0 comments on commit 968f9ee

Please sign in to comment.