Skip to content

Commit

Permalink
feat: add github workflows and nix checks
Browse files Browse the repository at this point in the history
  • Loading branch information
headblockhead committed Aug 17, 2024
1 parent 8dc385a commit f4c5d11
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 17 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build-library.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Build with Nix
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix build '.?submodules=1#squirrel'
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test with Nix
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix flake check -v
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Nix ignores
result

# CMake ignores
CMakeLists.txt.user
CMakeCache.txt
Expand Down
34 changes: 34 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{ lib
, gcc
, gnumake
, cmake
, stdenv
}:

stdenv.mkDerivation {
pname = "squirrel";
version = "0.0.0";

src = ./.;

nativeBuildInputs = [ cmake gnumake ];
buildInputs = [ ];

cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_C_COMPILER=${gcc}/bin/gcc"
"-DCMAKE_CXX_COMPILER=${gcc}/bin/g++"
];

installPhase = ''cp -r . $out'';

checkPhase = ''make -C ./build test'';

meta = with lib; {
homepage = "https://github.com/headblockhead/squirrel";
description = "Keyboard firmware library inspired by QMK.";
licencse = licenses.mit;
platforms = with platforms; linux;
};
}

8 changes: 4 additions & 4 deletions flake.lock

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

31 changes: 18 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
description = "Tools for developing and building SQUIRREL";
description = "Tools for developing, building and testing SQUIRREL";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
xc.url = "github:joerdav/xc";
};
Expand All @@ -14,25 +14,30 @@
overlays = [
(final: prev: {
xc = inputs.xc.packages.x86_64-linux.xc;
picotool = pkgs.callPackage ./picotool.nix {
pico-sdk = pkgs.callPackage ./pico-sdk.nix { };
};
pico-sdk = pkgs.callPackage ./pico-sdk.nix { };
})
];
};
in
{
packages.default = pkgs.callPackage ./default.nix { };
# Development shell (nix develop)
devShells.default = pkgs.mkShell {
buildInputs = [
inputs.xc

pkgs.cmake
pkgs.gcc
pkgs.ccls
pkgs.python39
pkgs.gnumake
pkgs.git
pkgs.cacert
buildInputs = with pkgs; [
xc
cmake
gcc
ccls
gnumake
git
cacert
];
};
# The firmware (nix build)
packages.squirrel = pkgs.callPackage ./default.nix { };
checks.squirrel-tests = pkgs.callPackage ./tests.nix { };
}
);
}
35 changes: 35 additions & 0 deletions tests.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ lib
, gcc
, gnumake
, cmake
, stdenv
}:

stdenv.mkDerivation {
pname = "squirrel-tests";
version = "0.0.0";

src = ./.;

nativeBuildInputs = [ cmake gnumake ];
buildInputs = [ ];

cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Testing"
"-DCMAKE_C_COMPILER=${gcc}/bin/gcc"
"-DCMAKE_CXX_COMPILER=${gcc}/bin/g++"
];

installPhase = ''
cd tests
ctest --timeout 60 # tests should never take longer than 60 seconds each to complete.
cp -r . $out'';

meta = with lib; {
homepage = "https://github.com/headblockhead/squirrel";
description = "Keyboard firmware library inspired by QMK.";
licencse = licenses.mit;
platforms = with platforms; linux;
};
}

0 comments on commit f4c5d11

Please sign in to comment.