-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
flake.nix
120 lines (112 loc) · 3.78 KB
/
flake.nix
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{
# https://github.com/Mic92/buildbot-nix
description = "A nixos module to make buildbot a proper Nix-CI.";
inputs = {
nixpkgs.url = "github:Nixos/nixpkgs/nixos-unstable-small";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
# used for development
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
hercules-ci-effects.inputs.nixpkgs.follows = "nixpkgs";
hercules-ci-effects.inputs.flake-parts.follows = "flake-parts";
};
outputs =
inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{
lib,
config,
withSystem,
...
}:
{
imports =
[
./nix/checks/flake-module.nix
]
++ inputs.nixpkgs.lib.optional (inputs.treefmt-nix ? flakeModule) ./nix/treefmt/flake-module.nix
++ inputs.nixpkgs.lib.optionals (inputs.hercules-ci-effects ? flakeModule) [
inputs.hercules-ci-effects.flakeModule
{
herculesCI = herculesCI: {
onPush.default.outputs.effects.deploy = withSystem config.defaultEffectSystem (
{ pkgs, hci-effects, ... }:
hci-effects.runIf (herculesCI.config.repo.branch == "main") (
hci-effects.mkEffect {
effectScript = ''
echo "${builtins.toJSON { inherit (herculesCI.config.repo) branch tag rev; }}"
${pkgs.hello}/bin/hello
'';
}
)
);
};
}
];
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
flake = {
nixosModules.buildbot-master.imports = [
./nix/master.nix
];
nixosModules.buildbot-worker.imports = [
./nix/worker.nix
];
nixosConfigurations =
let
examplesFor =
system:
import ./examples {
inherit system;
inherit (inputs) nixpkgs;
buildbot-nix = self;
};
in
examplesFor "x86_64-linux" // examplesFor "aarch64-linux";
lib = {
interpolate = value: {
_type = "interpolate";
inherit value;
};
};
};
perSystem =
{
self',
pkgs,
system,
...
}:
{
packages =
{
default = pkgs.mkShell {
packages = [
pkgs.bashInteractive
pkgs.mypy
pkgs.ruff
];
};
buildbot-nix = pkgs.python3.pkgs.callPackage ./nix/buildbot-nix.nix { };
}
// lib.optionalAttrs pkgs.stdenv.isLinux {
buildbot-effects = pkgs.python3.pkgs.callPackage ./nix/buildbot-effects.nix { };
};
checks =
let
nixosMachines = lib.mapAttrs' (
name: config: lib.nameValuePair "nixos-${name}" config.config.system.build.toplevel
) ((lib.filterAttrs (name: _: lib.hasSuffix system name)) self.nixosConfigurations);
packages = lib.mapAttrs' (n: lib.nameValuePair "package-${n}") self'.packages;
devShells = lib.mapAttrs' (n: lib.nameValuePair "devShell-${n}") self'.devShells;
in
nixosMachines // packages // devShells;
};
}
);
}