From 6475e844a9deb6b3a721231e8617511251a2779f Mon Sep 17 00:00:00 2001 From: Naxdy Date: Sun, 27 Oct 2024 20:49:20 +0000 Subject: [PATCH] chore: improve flake & ci (#28) Reviewed-on: https://git.naxdy.org/NaxdyOrg/NaxGCC-FW/pulls/28 --- .forgejo/workflows/clippy-check.yml | 4 +-- .forgejo/workflows/nightly-release.yml | 6 ++-- flake.nix | 44 ++++++++++++++------------ 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.forgejo/workflows/clippy-check.yml b/.forgejo/workflows/clippy-check.yml index d04d941..d755c76 100644 --- a/.forgejo/workflows/clippy-check.yml +++ b/.forgejo/workflows/clippy-check.yml @@ -10,8 +10,6 @@ jobs: check: runs-on: nix-flakes - - steps: - uses: actions/checkout@v4 @@ -25,4 +23,4 @@ jobs: - name: Run Clippy run: | - nix build .#clippy --print-build-logs -j auto + nix flake check . --print-build-logs -j auto diff --git a/.forgejo/workflows/nightly-release.yml b/.forgejo/workflows/nightly-release.yml index b8949e9..4172b4f 100644 --- a/.forgejo/workflows/nightly-release.yml +++ b/.forgejo/workflows/nightly-release.yml @@ -21,9 +21,9 @@ jobs: cache: "${{ vars.PUBLIC_BINARY_CACHE_NAME }}" - uses: actions/checkout@v4 - - name: Run Clippy + - name: Run flake checks run: | - nix build .#clippy --print-build-logs -j auto + nix flake check . --print-build-logs -j auto - name: Build firmware image run: | @@ -38,7 +38,7 @@ jobs: git tag nightly -m "Nightly Release" git checkout nightly git push --set-upstream origin nightly --force - + - name: Publish nightly release uses: https://gitea.com/actions/gitea-release-action@v1.3.0 with: diff --git a/flake.nix b/flake.nix index d0cf0ad..5f2f211 100644 --- a/flake.nix +++ b/flake.nix @@ -47,33 +47,37 @@ CARGO_BUILD_TARGET = "thumbv6m-none-eabi"; in { - packages.default = self.packages.${system}.naxgcc-fw-uf2; + packages = { + default = self.packages.${system}.naxgcc-fw-uf2; - packages.naxgcc-fw-uf2 = pkgs.runCommandLocal "${self.packages.${system}.naxgcc-fw.pname}-uf2-${self.packages.${system}.naxgcc-fw.version}" { } '' - mkdir -p $out/bin - ${pkgs.elf2uf2-rs}/bin/elf2uf2-rs ${self.packages.${system}.naxgcc-fw}/bin/${self.packages.${system}.naxgcc-fw.pname} $out/bin/${self.packages.${system}.naxgcc-fw.pname}.uf2 - ''; + naxgcc-fw-uf2 = pkgs.runCommandLocal "${self.packages.${system}.naxgcc-fw.pname}-uf2-${self.packages.${system}.naxgcc-fw.version}" { } '' + mkdir -p $out/bin + ${pkgs.elf2uf2-rs}/bin/elf2uf2-rs ${self.packages.${system}.naxgcc-fw}/bin/${self.packages.${system}.naxgcc-fw.pname} $out/bin/${self.packages.${system}.naxgcc-fw.pname}.uf2 + ''; - packages.naxgcc-fw = pkgs.callPackage - ({ mode ? "build" }: naersk_lib.buildPackage { - pname = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name; - version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version; + naxgcc-fw = pkgs.callPackage + ({ mode ? "build" }: naersk_lib.buildPackage { + pname = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name; + version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version; - inherit mode; + inherit mode; - src = self; + src = self; - cargoBuildOptions = _orig: _orig ++ [ - "--target=${CARGO_BUILD_TARGET}" - ]; + cargoBuildOptions = _orig: _orig ++ [ + "--target=${CARGO_BUILD_TARGET}" + ]; - # if a tree falls in the forest and no one is around to hear it, does it make a sound? - DEFMT_LOG = "off"; - }) - { }; + # if a tree falls in the forest and no one is around to hear it, does it make a sound? + DEFMT_LOG = "off"; + }) + { }; + }; - packages.clippy = self.packages.${system}.naxgcc-fw.override { - mode = "clippy"; + checks = { + clippy = self.packages.${system}.naxgcc-fw.override { + mode = "clippy"; + }; }; devShells.default = pkgs.mkShell {