From 55a7a69d641605d61638820dd18e7f8b2d58c017 Mon Sep 17 00:00:00 2001 From: John Ogle Date: Tue, 13 Jan 2026 15:50:23 -0800 Subject: [PATCH] feat: Add nix-setup composite action Reusable action for Nix CI with caching: - DeterminateSystems/nix-installer-action for Nix installation - actions/cache@v4 for Nix store caching - Cache key based on flake.lock for per-repo isolation --- README.md | 40 +++++++++++++++++++++++++++++++++++++++- nix-setup/action.yml | 25 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 nix-setup/action.yml diff --git a/README.md b/README.md index 550d7d5..0c4c4d9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,41 @@ # gitea-actions -Reusable Gitea Actions for CI workflows \ No newline at end of file +Reusable Gitea Actions for CI workflows. + +## Actions + +### nix-setup + +Installs Nix and sets up Nix store caching for Gitea Actions workflows. + +**Features:** +- Uses DeterminateSystems/nix-installer-action for reliable Nix installation +- Caches `/nix/store`, `/nix/var/nix`, and `~/.cache/nix` +- Cache key based on `flake.lock` hash for automatic invalidation +- Each repo gets isolated cache (different flake.lock = different cache) + +**Usage:** + +```yaml +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: johno/gitea-actions/nix-setup@main + - run: nix flake check +``` + +**With custom cache prefix:** + +```yaml +- uses: johno/gitea-actions/nix-setup@main + with: + cache-name: 'my-project-' +``` + +**Inputs:** + +| Input | Description | Required | Default | +|-------|-------------|----------|---------| +| `cache-name` | Optional cache name prefix for disambiguation | No | `''` | diff --git a/nix-setup/action.yml b/nix-setup/action.yml new file mode 100644 index 0000000..b6cf321 --- /dev/null +++ b/nix-setup/action.yml @@ -0,0 +1,25 @@ +name: 'Nix Setup with Cache' +description: 'Install Nix and set up store caching' + +inputs: + cache-name: + description: 'Optional cache name prefix for disambiguation' + required: false + default: '' + +runs: + using: 'composite' + steps: + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@main + + - name: Cache Nix store + uses: actions/cache@v4 + with: + path: | + /nix/store + /nix/var/nix + ~/.cache/nix + key: nix-${{ inputs.cache-name }}${{ runner.os }}-${{ hashFiles('flake.lock') }} + restore-keys: | + nix-${{ inputs.cache-name }}${{ runner.os }}-