Skip to content

Commit 0360c5a

Browse files
authored
Merge pull request #520 from nix-community/niks3
add niks3 binary cache support
2 parents fd3cc9d + 61cfbef commit 0360c5a

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

nixosModules/master.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ in
4242
imports = [
4343
./packages.nix
4444
./cachix.nix
45+
./niks3.nix
4546
(mkRenamedOptionModule
4647
[
4748
"services"

nixosModules/niks3.nix

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
lib,
3+
config,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
cfg = config.services.buildbot-nix.master;
9+
interpolate = value: {
10+
_type = "interpolate";
11+
inherit value;
12+
};
13+
in
14+
{
15+
options.services.buildbot-nix.master.niks3 = {
16+
enable = lib.mkEnableOption "Enable niks3 integration";
17+
18+
serverUrl = lib.mkOption {
19+
type = lib.types.str;
20+
description = "niks3 server URL";
21+
example = "https://niks3.yourdomain.com";
22+
};
23+
24+
authTokenFile = lib.mkOption {
25+
type = lib.types.path;
26+
description = ''
27+
Path to a file containing the niks3 API authentication token.
28+
'';
29+
};
30+
31+
package = lib.mkOption {
32+
type = lib.types.package;
33+
default =
34+
pkgs.niks3 or (throw "niks3 package not found in pkgs. Please add niks3 flake input and overlay.");
35+
description = "The niks3 package to use";
36+
};
37+
};
38+
39+
config = lib.mkIf cfg.niks3.enable {
40+
systemd.services.buildbot-master.serviceConfig.LoadCredential = [
41+
"niks3-auth-token:${builtins.toString cfg.niks3.authTokenFile}"
42+
];
43+
44+
systemd.services.buildbot-worker.path = [ cfg.niks3.package ];
45+
46+
services.buildbot-nix.master.postBuildSteps = [
47+
{
48+
name = "Upload to niks3";
49+
environment = {
50+
NIKS3_SERVER_URL = cfg.niks3.serverUrl;
51+
};
52+
command = [
53+
"niks3" # note that this is the niks3 from the worker's $PATH
54+
"push"
55+
"--auth-token"
56+
(interpolate "%(secret:niks3-auth-token)s")
57+
(interpolate "result-%(prop:attr)s")
58+
];
59+
}
60+
];
61+
};
62+
}

0 commit comments

Comments
 (0)