Generates .gitlab-ci.yml from your flake outputs with automatic dependency tracking.
Add the following flake input:
gitlab-ci = {
url = "gitlab:platonic/gitlab-ci.nix";
inputs.nixpkgs.follows = "nixpkgs";
};And include it as an app in your flake outputs:
inputs@{ gitlab-ci, ... }:
{
apps = {
inherit (gitlab-ci.apps.x86_64-linux) gitlab-ci;
};
}Then generate your CI config:
nix run .#gitlab-ci > .gitlab-ci.ymlThe generator automatically creates CI jobs for:
- packages - Built in the
buildstage - checks - Built in the
teststage - devShells - Built in the
buildstage - apps - Verified in the
teststage
Jobs include automatic needs: dependencies based on derivation inputs, so checks that depend on packages will wait for those packages to build first.
Additionally, these jobs are always included:
flake:show- Validates flake structure (build stage)flake:check- Runsnix flake check(validate stage)gitlab-ci:check- Verifies.gitlab-ci.ymlis up to date (validate stage)
Customize the generated config by adding a gitlab output to your flake. This is an overlay function that receives the fully generated config and returns your modified version:
{
outputs = inputs: {
# ... your packages, checks, apps, etc.
# Overlay function: prev is the generated config
gitlab = prev: prev // {
# Add a deploy stage
stages = prev.stages ++ [ "deploy" ];
# Add a custom deploy job
deploy = {
stage = "deploy";
script = [ "nix run .#deploy -L" ];
rules = [{ "if" = "$CI_COMMIT_BRANCH == \"master\""; }];
};
# Modify a generated job's needs
"checks:integration" = prev."checks:integration" // {
needs = prev."checks:integration".needs ++ [ "deploy" ];
};
# Override variables
variables = prev.variables // {
CUSTOM_VAR = "value";
};
# Remove a job entirely
"flake:check" = null;
};
};
}The overlay gives you complete control - modify generated jobs, add new ones, change stages, remove jobs. You get the full generated config as prev and return whatever you want.
