-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake-module.nix
More file actions
79 lines (73 loc) · 2.67 KB
/
flake-module.nix
File metadata and controls
79 lines (73 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{ config, lib, ... }:
let
inherit (lib) types;
in
{
options = {
first-ci-kit.pipelines = lib.mkOption {
type = types.lazyAttrsOf (types.submoduleWith { modules = [ ./module ]; });
default = { };
description = "Pipelines for CI.";
};
};
config.perSystem =
{ pkgs, ... }:
let
# Collect all pipeline files (top-level + children) for a given backend getter.
# Returns a list of { name = "<key>.yml"; path = <drv>; } suitable for linkFarm.
allPipelineFiles =
getter:
lib.mapAttrsToList (name: value: {
name = "${name}.yml";
path = getter value;
}) config.first-ci-kit.pipelines
++ lib.concatLists (
lib.mapAttrsToList (
parentName: parentValue:
lib.mapAttrsToList (childName: childValue: {
name = "${parentName}-${childName}.yml";
path = getter childValue;
}) parentValue.pipelines
) config.first-ci-kit.pipelines
);
in
{
packages.gha-path-changes = pkgs.callPackage ./packages/gha-path-changes { };
legacyPackages = lib.mkMerge [
(lib.mapAttrs' (name: value: {
name = "ci-pipeline-github-actions-${name}";
value = value.github-actions.file;
}) config.first-ci-kit.pipelines)
(lib.mapAttrs' (name: value: {
name = "ci-pipeline-gitlab-ci-${name}";
value = value.gitlab-ci.file;
}) config.first-ci-kit.pipelines)
# Child pipeline legacyPackages: ci-pipeline-{backend}-{parent}-{child}
(lib.mkMerge (
lib.mapAttrsToList (
parentName: parentValue:
lib.mkMerge [
(lib.mapAttrs' (childName: childValue: {
name = "ci-pipeline-gitlab-ci-${parentName}-${childName}";
value = childValue.gitlab-ci.file;
}) parentValue.pipelines)
(lib.mapAttrs' (childName: childValue: {
name = "ci-pipeline-github-actions-${parentName}-${childName}";
value = childValue.github-actions.file;
}) parentValue.pipelines)
]
) config.first-ci-kit.pipelines
))
# Bundle packages: one derivation per backend containing all pipeline files.
# Used by git hooks to avoid N separate nix build invocations (one eval each).
{
ci-pipelines-github-actions = pkgs.linkFarm "ci-pipelines-github-actions" (
allPipelineFiles (p: p.github-actions.file)
);
ci-pipelines-gitlab-ci = pkgs.linkFarm "ci-pipelines-gitlab-ci" (
allPipelineFiles (p: p.gitlab-ci.file)
);
}
];
};
}