Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions .github/actions/setup-nix/action.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
name: 'Setup Nix'
description: 'Install Nix and optionally configure the shared cache-nix-action'
description: 'Install Nix and configure the eupkgs Cachix binary cache'

inputs:
cache-key:
description: 'Distinctive segment for the cache primary key (leave empty to skip caching)'
cachix-cache:
description: 'Cachix cache name (leave empty to skip Cachix)'
required: false
default: 'eupkgs'
cachix-auth-token:
description: 'Cachix token used to push build results'
required: false
default: ''
cache-hash-files:
description: 'Newline-separated glob list passed to hashFiles() for the primary key suffix'
cachix-skip-push:
description: 'Only pull from Cachix, even when an auth token is provided'
required: false
default: 'flake.lock'
default: 'true'

runs:
using: 'composite'
steps:
- uses: DeterminateSystems/nix-installer-action@v22

- if: inputs.cache-key != ''
uses: nix-community/cache-nix-action@v7
- name: Configure read-only Cachix access
if: inputs.cachix-cache != '' && inputs.cachix-auth-token == ''
uses: cachix/cachix-action@v17
with:
name: ${{ inputs.cachix-cache }}
skipPush: true

- name: Configure authenticated Cachix access
if: inputs.cachix-cache != '' && inputs.cachix-auth-token != ''
uses: cachix/cachix-action@v17
with:
primary-key: nix-${{ runner.os }}-${{ inputs.cache-key }}-${{ hashFiles(inputs.cache-hash-files) }}
restore-prefixes-first-match: nix-${{ runner.os }}-${{ inputs.cache-key }}-
purge: true
purge-prefixes: nix-${{ runner.os }}-${{ inputs.cache-key }}-
purge-created: 0
purge-last-accessed: 604800
purge-primary-key: never
name: ${{ inputs.cachix-cache }}
authToken: ${{ inputs.cachix-auth-token }}
skipPush: ${{ inputs.cachix-skip-push }}
8 changes: 5 additions & 3 deletions .github/workflows/build-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Install Nix
uses: ./.github/actions/setup-nix
with:
cache-key: build-packages-detect
cachix-cache: ${{ vars.CACHIX_CACHE_NAME || 'eupkgs' }}

- name: Detect packages
id: detect
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Install Nix
uses: ./.github/actions/setup-nix
with:
cache-key: build-packages-flake-check
cachix-cache: ${{ vars.CACHIX_CACHE_NAME || 'eupkgs' }}

- name: Check flake outputs without building packages
run: nix flake check --accept-flake-config --impure --no-build
Expand All @@ -99,7 +99,9 @@ jobs:
- name: Install Nix
uses: ./.github/actions/setup-nix
with:
cache-key: build-packages-${{ matrix.platform }}
cachix-cache: ${{ vars.CACHIX_CACHE_NAME || 'eupkgs' }}
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
cachix-skip-push: ${{ github.event_name == 'pull_request' }}

- name: Build selected by-name packages
shell: bash
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,23 @@ although it can be used by other repos as well too

### Binary cache

This flake does not configure a project binary cache. Builds use the substituters
from your local Nix configuration.
This flake advertises the public `eupkgs` Cachix cache through `nixConfig`:

```nix
extra-substituters = [ "https://eupkgs.cachix.org" ];
extra-trusted-public-keys = [
"eupkgs.cachix.org-1:V9Y0HdASNNSU9U6EkXhR1j85bZGRtNgW7wSyTiQrwGU="
];
```

Accept the flake configuration when Nix prompts to download prebuilt packages
from Cachix instead of building them locally. For non-interactive use, pass
`--accept-flake-config`. Multi-user Nix installations may require a trusted
administrator to add the same substituter and public key system-wide.

GitHub Actions pulls from this cache for all checks. Builds on `master` and
manually dispatched builds also push successful results using the repository's
`CACHIX_AUTH_TOKEN`; pull requests remain read-only.

### Add as a flake input

Expand Down
7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
{
description = "EUVlok Packages - overlay for Nixpkgs";

nixConfig = {
extra-substituters = [ "https://eupkgs.cachix.org" ];
extra-trusted-public-keys = [
"eupkgs.cachix.org-1:V9Y0HdASNNSU9U6EkXhR1j85bZGRtNgW7wSyTiQrwGU="
];
};

inputs.nixpkgs.url = "github:NixOS/nixpkgs";

outputs =
Expand Down
Loading