mirror of
https://github.com/numtide/treefmt.git
synced 2024-10-27 01:44:13 +03:00
Merge pull request #5 from numtide/feat/nix-ci
feat: add nix github workflow
This commit is contained in:
commit
7aa2ad6095
36
.github/workflows/nix.yml
vendored
Normal file
36
.github/workflows/nix.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
name: Nix Flake Actions
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
nix-matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v26
|
||||
- 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@v26
|
||||
- uses: cachix/cachix-action@v14
|
||||
with:
|
||||
name: numtide
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
- run: nix build -L ".#${{ matrix.attr }}"
|
43
flake.lock
43
flake.lock
@ -38,7 +38,9 @@
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1712014858,
|
||||
@ -111,6 +113,26 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-github-actions": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1703863825,
|
||||
"narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-github-actions",
|
||||
"rev": "5163432afc817cf8bd1f031418d1869e4c9d5547",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-github-actions",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1714253743,
|
||||
@ -127,24 +149,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"lastModified": 1711703276,
|
||||
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"dir": "lib",
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
@ -152,6 +156,7 @@
|
||||
"flake-parts": "flake-parts",
|
||||
"gomod2nix": "gomod2nix",
|
||||
"nix-filter": "nix-filter",
|
||||
"nix-github-actions": "nix-github-actions",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
|
11
flake.nix
11
flake.nix
@ -3,7 +3,10 @@
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-parts = {
|
||||
url = "github:hercules-ci/flake-parts";
|
||||
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
};
|
||||
treefmt-nix = {
|
||||
# todo switch back to numtide/treefmt-nix once merged
|
||||
url = "github:brianmcgee/treefmt-nix/feat/pipelines";
|
||||
@ -16,10 +19,14 @@
|
||||
gomod2nix = {
|
||||
url = "github:nix-community/gomod2nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.flake-utils.follows ="devshell/flake-utils";
|
||||
inputs.flake-utils.follows = "devshell/flake-utils";
|
||||
};
|
||||
nix-filter.url = "github:numtide/nix-filter";
|
||||
flake-compat.url = "github:nix-community/flake-compat";
|
||||
nix-github-actions = {
|
||||
url = "github:nix-community/nix-github-actions";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs @ {flake-parts, ...}:
|
||||
|
@ -1,5 +1,16 @@
|
||||
{lib, ...}: {
|
||||
{
|
||||
lib,
|
||||
inputs,
|
||||
self,
|
||||
...
|
||||
}: {
|
||||
# generate github actions matrix using the flake's checks
|
||||
flake.githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
|
||||
checks = lib.getAttrs ["x86_64-linux" "x86_64-darwin"] self.checks;
|
||||
};
|
||||
|
||||
perSystem = {self', ...}: {
|
||||
# mixin every package
|
||||
checks = with lib; mapAttrs' (n: nameValuePair "package-${n}") self'.packages;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user