Skip to content

Commit

Permalink
fix: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
deemp committed Aug 29, 2023
1 parent 0782e5b commit 68b41d6
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This action is based on [actions/cache](https://github.com/actions/cache).
## Limitations

* `GitHub` allows only 10GB of caches and then removes the least recently used entries (see its [eviction policy](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy)).
* Can be overcome by merging similar caches (see [Merge caches](#merge-caches))
* `cache-nix-action` restores and saves the whole `/nix` directory.
* `cache-nix-action` requires `nix-quick-install-action` (see [Approach](#approach)).
* Store size is limited by a runner storage size ([link](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources)).
Expand Down Expand Up @@ -65,21 +66,13 @@ This action inherits some [inputs](#inputs) and [outputs](#outputs) of `actions/
Note:

* `cache-nix-action` purges only caches specific to a branch that has triggered a workflow.
* `*-max-age` is used before saving a cache.
* `*-max-age` is relative to the time before saving a new cache.

### Removed inputs

The `cache-nix-action` doesn't provide the `path` input from the original [inputs](#inputs) of `actions/cache` due to [limitations](#limitations).
Instead, the `cache-nix-action` caches `/nix`, `~/.cache/nix`, `~root/.cache/nix` paths by default as suggested [here](https://github.com/divnix/nix-cache-action/blob/b14ec98ae694c754f57f8619ea21b6ab44ccf6e7/action.yml#L7).

### Garbage collection parameters

On `Linux` runners, when `gc-linux` is `true`, when a cache size is greater than `gc-max-cache-size-linux`, this action will run `nix store gc --max R` before saving a cache.
Here, `R` is `max(0, S - gc-max-store-size-linux)`, where `S` is the current store size.
Respective conditions hold for `macOS` runners.

There are alternative approaches to garbage collection (see [Garbage collection](#garbage-collection)).

## Usage

* This action **must** be used with [nix-quick-install-action](https://github.com/nixbuild/nix-quick-install-action).
Expand Down Expand Up @@ -122,20 +115,34 @@ See [ci.yaml](.github/workflows/ci.yaml).

* Use [action-tmate](https://github.com/mxschmitt/action-tmate) to debug on a runner via SSH.

### Garbage collection parameters

On `Linux` runners, when `gc-linux` is `true`, when a cache size is greater than `gc-max-cache-size-linux`, this action will run `nix store gc --max R` before saving a cache.
Here, `R` is `max(0, S - gc-max-store-size-linux)`, where `S` is the current store size.
Respective conditions hold for `macOS` runners.

There are alternative approaches to garbage collection (see [Garbage collection](#garbage-collection)).

### Purge old caches

The `cache-nix-action` allows to delete old caches before saving a new cache (see [New inputs](#new-inputs)).
The `cache-nix-action` allows to delete old caches after saving a new cache (see [New inputs](#new-inputs)).

The [purge-cache](https://github.com/MyAlbum/purge-cache) action allows to remove caches based on their `last accessed` or `created` time without branch limitations.

Alternatively, you can use the [GitHub Actions Cache API](https://docs.github.com/en/rest/actions/cache).

### Merge caches

`GitHub` evicts LRU caches when their total size exceeds `10GB` (see [Limitations](#limitations)).

If you have multiple similar caches, you can merge them into a single cache and store just it to save space.

See the `make-similar-caches` and `merge-similar-caches` jobs in the [example workflow](#example-workflow).

### Get more space on a runner

The [jlumbroso/free-disk-space](https://github.com/jlumbroso/free-disk-space) action frees `~30GB` of disk space in several minutes.

<!-- TODO combine caches -->

## Caching approaches

Discussed in more details [here](https://github.com/DeterminateSystems/magic-nix-cache-action/issues/16) and [here](https://github.com/nixbuild/nix-quick-install-action/issues/33).
Expand Down

0 comments on commit 68b41d6

Please sign in to comment.