add worker module
This commit is contained in:
parent
72d012ca29
commit
9ce55f46f4
|
@ -1,20 +1,43 @@
|
||||||
{ config
|
{ config
|
||||||
, pkgs
|
, pkgs
|
||||||
|
, lib
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
package = pkgs.buildbot-worker;
|
cfg = config.services.buildbot-nix.worker;
|
||||||
python = package.pythonModule;
|
|
||||||
home = "/var/lib/buildbot-worker";
|
home = "/var/lib/buildbot-worker";
|
||||||
buildbotDir = "${home}/worker";
|
buildbotDir = "${home}/worker";
|
||||||
|
python = cfg.package.pythonModule;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
options = {
|
||||||
|
services.buildbot-nix.worker = {
|
||||||
|
enable = lib.mkEnableOption "buildbot-worker";
|
||||||
|
package = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = pkgs.buildbot-worker;
|
||||||
|
defaultText = "pkgs.buildbot-worker";
|
||||||
|
description = "The buildbot-worker package to use.";
|
||||||
|
};
|
||||||
|
masterUrl = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "tcp:host=localhost:port=9989";
|
||||||
|
description = "The buildbot master url.";
|
||||||
|
};
|
||||||
|
workerPasswordFile = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "/var/lib/buildbot-worker/worker-password";
|
||||||
|
description = "The buildbot worker password file.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = lib.mkIf config.services.buildbot-worker.enable {
|
||||||
nix.settings.allowed-users = [ "buildbot-worker" ];
|
nix.settings.allowed-users = [ "buildbot-worker" ];
|
||||||
users.users.buildbot-worker = {
|
users.users.buildbot-worker = {
|
||||||
description = "Buildbot Worker User.";
|
description = "Buildbot Worker User.";
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
home = "/var/lib/buildbot-worker";
|
inherit home;
|
||||||
group = "buildbot-worker";
|
group = "buildbot-worker";
|
||||||
useDefaultShell = true;
|
useDefaultShell = true;
|
||||||
};
|
};
|
||||||
|
@ -32,21 +55,21 @@ in
|
||||||
pkgs.gh
|
pkgs.gh
|
||||||
pkgs.nix
|
pkgs.nix
|
||||||
];
|
];
|
||||||
environment.PYTHONPATH = "${python.withPackages (_: [package])}/${python.sitePackages}";
|
environment.PYTHONPATH = "${python.withPackages (_: [cfg.package])}/${python.sitePackages}";
|
||||||
environment.MASTER_URL = ''tcp:host=localhost:port=9989'';
|
environment.MASTER_URL = ''tcp:host=localhost:port=9989'';
|
||||||
environment.BUILDBOT_DIR = buildbotDir;
|
environment.BUILDBOT_DIR = buildbotDir;
|
||||||
environment.WORKER_PASSWORD_FILE = config.sops.secrets.buildbot-nix-worker-password.path;
|
environment.WORKER_PASSWORD_FILE = cfg.workerPasswordFile;
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
User = "buildbot-worker";
|
User = "buildbot-worker";
|
||||||
Group = "buildbot-worker";
|
Group = "buildbot-worker";
|
||||||
WorkingDirectory = home;
|
WorkingDirectory = "/var/lib/buildbot-worker";
|
||||||
|
|
||||||
# Restart buildbot with a delay. This time way we can use buildbot to deploy itself.
|
# Restart buildbot with a delay. This time way we can use buildbot to deploy itself.
|
||||||
ExecReload = "+${pkgs.systemd}/bin/systemd-run --on-active=60 ${pkgs.systemd}/bin/systemctl restart buildbot-worker";
|
ExecReload = "+${pkgs.systemd}/bin/systemd-run --on-active=60 ${pkgs.systemd}/bin/systemctl restart buildbot-worker";
|
||||||
ExecStart = "${python.pkgs.twisted}/bin/twistd --nodaemon --pidfile= --logfile - --python ${./worker.py}";
|
ExecStart = "${python.pkgs.twisted}/bin/twistd --nodaemon --pidfile= --logfile - --python ${../buildbot_nix/worker.py}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
sops.secrets.buildbot-nix-worker-password.owner = "buildbot-worker";
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue