diff --git a/.github/workflows/nix-flake.yml b/.github/workflows/nix-flake.yml index 023bf87..38eb173 100644 --- a/.github/workflows/nix-flake.yml +++ b/.github/workflows/nix-flake.yml @@ -9,26 +9,15 @@ on: workflow_dispatch: jobs: - nix-matrix: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} + check: + runs-on: ubuntu-22.04 + permissions: + id-token: "write" + contents: "read" steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v24 - - id: set-matrix - name: Generate Nix Matrix - run: | - set -Eeu - matrix="$(nix eval --json '.#githubActions.matrix')" - echo "matrix=$matrix" >> "$GITHUB_OUTPUT" - - nix-build: - needs: nix-matrix - runs-on: ${{ matrix.os }} - strategy: - matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}} - steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v24 - - run: nix build -L ".#${{ matrix.attr }}" + - uses: actions/checkout@v3 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: DeterminateSystems/flake-checker-action@main + - name: Run `nix build` + run: nix build . \ No newline at end of file diff --git a/flake.nix b/flake.nix index 36d40c2..bddcb3f 100644 --- a/flake.nix +++ b/flake.nix @@ -3,28 +3,19 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; - flake-parts.inputs.nixpkgs.follows = "nixpkgs"; - systems.url = "github:nix-systems/default"; - systems.inputs.nixpkgs.follows = "nixpkgs"; - - nix-github-actions.url = "github:nix-community/nix-github-actions"; - nix-github-actions.inputs.nixpkgs.follows = "nixpkgs"; # Dev tools treefmt-nix.url = "github:numtide/treefmt-nix"; treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = inputs: + outputs = inputs@{ flake-parts, ... }: inputs.flake-parts.lib.mkFlake { inherit inputs; } { systems = import inputs.systems; imports = [ inputs.treefmt-nix.flakeModule ]; - flake = { config, self', inputs', ... }: { - githubActions = inputs.nix-github-actions.lib.mkGithubMatrix { checks = self'.packages; }; - }; perSystem = { config, self', pkgs, lib, system, ... }: let cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); @@ -36,8 +27,12 @@ name = "rust-toolchain"; paths = [ pkgs.rustc pkgs.cargo pkgs.cargo-watch pkgs.rust-analyzer pkgs.rustPlatform.rustcSrc ]; }; + checks = { + x86_64-linux.default = config.packages.default; + }; in { + githubActions = inputs.nix-github-actions.lib.mkGithubMatrix { inherit checks; }; # Rust package packages.default = pkgs.rustPlatform.buildRustPackage { inherit (cargoToml.package) name version;