@dusksystems/nix-cache-action
v1.4.1
Published
A GitHub Action for caching Nix.
Downloads
77
Readme
nix-cache-action
A GitHub Action for caching Nix.
Usage
- name: Cache Nix
uses: DuskSystems/nix-cache-action@${VERSION}
with:
key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.lock', '**/*.nix') }}
restore-keys: |
nix-${{ runner.os }}-${{ runner.arch }}-Why?
Efficiency
nix-community/cache-nix-actioncaches the entire/nixdirectory.DeterminateSystems/magic-nix-cachecaches every store path closure.DuskSystems/nix-cache-actioncaches only what can't be fetched from substituters.
As an example, a project with this Nix shell:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
# System
pkg-config
];
buildInputs = with pkgs; [
# Rust
rust-bin.stable.latest.default
cargo-nextest
cargo-shear
# System
openssl
# Spellchecking
typos
# Nix
nixfmt
];
}Results in the following cache save stats:
| Action | Entries | Size |
| ------------------------------------ | ------- | ------- |
| nix-community/cache-nix-action | 1 | 682 MiB |
| DeterminateSystems/magic-nix-cache | 200 | 523 MiB |
| DuskSystems/nix-cache-action | 1 | 377 MiB |
The tradeoff is this relies on substituters being consistently available and fast to fetch from at restore time.
Compatibility
Since this action uses @actions/cache, it should be compatible with alternative GitHub Actions runners that provide their own cache backends.
License
nix-cache-action is licensed under the terms of both the MIT License and the Apache License (Version 2.0).
