Merge branch 'feat/improve-caching' into 'main'

feat: add support for Gitlab CI cache

Closes #2

See merge request TECHNOFAB/nix-gitlab-ci!4
This commit is contained in:
TECHNOFAB 2024-09-13 18:43:56 +00:00
commit edaf08205b
4 changed files with 149 additions and 47 deletions

View file

@ -1,9 +1,10 @@
# Nix Gitlab CI
Flake module which allows generating a `.gitlab-ci.yml` from Nix.
This allows easily using any Nix package in CI.
Also makes it possible to split CI parts in a separate module
which can be imported in multiple projects.
Also makes it possible to split CI parts in a separate module which can be imported in multiple projects.
## Usage
@ -25,7 +26,7 @@ which can be imported in multiple projects.
jobs = {
"test" = {
stage = "test";
deps = [pkgs.unixtools.ping];
nix.deps = [pkgs.unixtools.ping];
script = [
"ping -c 5 8.8.8.8"
];
@ -47,3 +48,16 @@ include:
image_tag: latest-cachix
```
## Utilities
### Disable Caching temporarily
To disable any of the provided caches for a pipeline one can set `NIX_CI_DISABLE_CACHE` to
anything non-empty (eg. "yes") when triggering the pipeline.
The `build:nix-ci` job has a different special environment variable `NIX_CI_SKIP_CACHE`
(useful if the generated pipeline is outdated but caching should generally still take place).
## Thanks to
Some parts of this implementation are adapted/inspired from https://gitlab.com/Cynerd/gitlab-ci-nix