Allows (advanced) configuration of GitLab CI using Nix. https://nix-gitlab-ci.projects.tf
Find a file
2024-10-02 18:26:14 +02:00
lib fix(utils): migrate utils to the new syntax aswell 2024-10-02 18:26:14 +02:00
templates feat: improve caching 2024-09-13 18:43:56 +00:00
.envrc chore: initial commit 2024-01-14 16:45:07 +01:00
.gitignore chore: initial commit 2024-01-14 16:45:07 +01:00
.gitlab-ci.yml chore(CI): build image on tag & tag images with short sha instead of date 2024-09-13 17:54:24 +02:00
flake.lock chore: add treefmt and format files 2024-09-13 17:22:38 +02:00
flake.nix feat: improve caching 2024-09-13 18:43:56 +00:00
gitlab-ci.yml chore: add treefmt and format files 2024-09-13 17:22:38 +02:00
README.md chore(README): bump component version 2024-09-16 09:41:08 +00:00

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.

Usage

# flake.nix
{
  ...
  inputs.nix-gitlab-ci.url = "gitlab:TECHNOFAB/nix-gitlab-ci?dir=lib";
  
  outputs = {...}: flake-parts.lib.mkFlake {...} {
    imports = [
      inputs.nix-gitlab-ci.flakeModule
    ];
    ...
    
    perSystem = {pkgs, ...}: {
      ci = {
        stages = ["test"];
        jobs = {
          "test" = {
            stage = "test";
            nix.deps = [pkgs.unixtools.ping];
            script = [
              "ping -c 5 8.8.8.8"
            ];
          };
        };
      };
      ...
    }
  }
}
# .gitlab-ci.yml
include:
  - component: gitlab.com/TECHNOFAB/nix-gitlab-ci/nix-gitlab-ci@1.0.1
    inputs:
      # specify inputs here, for example:
      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