Github action to use an Attic binary cache https://cachix.org
  • TypeScript 67.8%
  • Nix 26.9%
  • JavaScript 5.3%
Find a file
2019-12-17 19:27:23 +01:00
.github/workflows bump 2019-11-20 15:41:46 +01:00
__tests__ saneSplit -> nonEmptySplit 2019-10-03 13:26:42 +02:00
lib bump 2019-10-03 17:41:53 +02:00
src Update src/main.ts 2019-10-03 16:42:28 +02:00
.gitignore Initial commit 2019-09-30 15:32:36 +02:00
action.yml Support pull requests 2019-10-03 16:32:37 +02:00
jest.config.js Initial commit 2019-09-30 15:32:36 +02:00
LICENSE Split Nix installation into separate action 2019-10-02 16:25:24 +02:00
package.json Split Nix installation into separate action 2019-10-02 16:25:24 +02:00
README.md README: explain why this action is needed and elaborate on setup 2019-12-17 19:27:23 +01:00
test.nix fix for #3 2019-10-03 15:43:16 +02:00
tsconfig.json Initial commit 2019-09-30 15:32:36 +02:00
yarn.lock Install Nix via the action 2019-10-01 11:54:05 +02:00

cachix-action

github actions badge

Build software only once using Nix with the help of Cachix.

This action will configure Cachix and invoke nix-build.

Why do I need this

Because you'd like for your CI to be fast. Let me explain.

Caching on a typical CI doesn't work in favor of Nix.

/nix/store is a global storage of everything Nix operates on. These are your sources, patches, tarballs, packages, configuration.

Caching /nix/store is time consuming as Nix only appends store paths to it. As you invoke new builds, those will contain all your sources throughout the whole history of your build.

Garbage collecting is also suboptimal, as caching is hard to invalidate correctly between different changes and branches.

Cachix avoids this by keeping your /nix/store hosted and only downloads the bits you need for the given build (in parallel) using Nix substituters.

Usage

  1. Login to Cachix and create a new cache.

    1. Follow getting started to create your signing key
    2. Backup the signing key in the process.
  2. As an admin of your github repository:

    1. Click on Settings
    2. Click on Secrets (If missing, you need to sign up first for actions beta)
    3. Add your signing key value under name CACHIX_SIGNING_KEY.
  3. Create .github/workflows/test.yml in your repo with the following contents:

name: "Test"
on:
  pull_request:
  push:
jobs:
  tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: cachix/install-nix-action@v6
    - uses: cachix/cachix-action@v2
      with:
        name: mycache
        signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
        # Only needed for private caches
        authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

See action.yml for all options.


Hacking

Install the dependencies

$ yarn install

Build the typescript

$ yarn build

Run the tests ✔️

$ yarn test