add worker module
This commit is contained in:
parent
72d012ca29
commit
9ce55f46f4
103
nix/worker.nix
103
nix/worker.nix
|
@ -1,52 +1,75 @@
|
||||||
{ 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
|
||||||
{
|
{
|
||||||
nix.settings.allowed-users = [ "buildbot-worker" ];
|
options = {
|
||||||
users.users.buildbot-worker = {
|
services.buildbot-nix.worker = {
|
||||||
description = "Buildbot Worker User.";
|
enable = lib.mkEnableOption "buildbot-worker";
|
||||||
isSystemUser = true;
|
package = lib.mkOption {
|
||||||
createHome = true;
|
type = lib.types.str;
|
||||||
home = "/var/lib/buildbot-worker";
|
default = pkgs.buildbot-worker;
|
||||||
group = "buildbot-worker";
|
defaultText = "pkgs.buildbot-worker";
|
||||||
useDefaultShell = true;
|
description = "The buildbot-worker package to use.";
|
||||||
};
|
};
|
||||||
users.groups.buildbot-worker = { };
|
masterUrl = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
systemd.services.buildbot-worker = {
|
default = "tcp:host=localhost:port=9989";
|
||||||
reloadIfChanged = true;
|
description = "The buildbot master url.";
|
||||||
description = "Buildbot Worker.";
|
};
|
||||||
after = [ "network.target" "buildbot-master.service" ];
|
workerPasswordFile = lib.mkOption {
|
||||||
wantedBy = [ "multi-user.target" ];
|
type = lib.types.str;
|
||||||
path = [
|
default = "/var/lib/buildbot-worker/worker-password";
|
||||||
pkgs.cachix
|
description = "The buildbot worker password file.";
|
||||||
pkgs.git
|
};
|
||||||
pkgs.openssh
|
};
|
||||||
pkgs.gh
|
};
|
||||||
pkgs.nix
|
config = lib.mkIf config.services.buildbot-worker.enable {
|
||||||
];
|
nix.settings.allowed-users = [ "buildbot-worker" ];
|
||||||
environment.PYTHONPATH = "${python.withPackages (_: [package])}/${python.sitePackages}";
|
users.users.buildbot-worker = {
|
||||||
environment.MASTER_URL = ''tcp:host=localhost:port=9989'';
|
description = "Buildbot Worker User.";
|
||||||
environment.BUILDBOT_DIR = buildbotDir;
|
isSystemUser = true;
|
||||||
environment.WORKER_PASSWORD_FILE = config.sops.secrets.buildbot-nix-worker-password.path;
|
createHome = true;
|
||||||
|
inherit home;
|
||||||
serviceConfig = {
|
group = "buildbot-worker";
|
||||||
Type = "simple";
|
useDefaultShell = true;
|
||||||
User = "buildbot-worker";
|
};
|
||||||
Group = "buildbot-worker";
|
users.groups.buildbot-worker = { };
|
||||||
WorkingDirectory = home;
|
|
||||||
|
systemd.services.buildbot-worker = {
|
||||||
# Restart buildbot with a delay. This time way we can use buildbot to deploy itself.
|
reloadIfChanged = true;
|
||||||
ExecReload = "+${pkgs.systemd}/bin/systemd-run --on-active=60 ${pkgs.systemd}/bin/systemctl restart buildbot-worker";
|
description = "Buildbot Worker.";
|
||||||
ExecStart = "${python.pkgs.twisted}/bin/twistd --nodaemon --pidfile= --logfile - --python ${./worker.py}";
|
after = [ "network.target" "buildbot-master.service" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
path = [
|
||||||
|
pkgs.cachix
|
||||||
|
pkgs.git
|
||||||
|
pkgs.openssh
|
||||||
|
pkgs.gh
|
||||||
|
pkgs.nix
|
||||||
|
];
|
||||||
|
environment.PYTHONPATH = "${python.withPackages (_: [cfg.package])}/${python.sitePackages}";
|
||||||
|
environment.MASTER_URL = ''tcp:host=localhost:port=9989'';
|
||||||
|
environment.BUILDBOT_DIR = buildbotDir;
|
||||||
|
environment.WORKER_PASSWORD_FILE = cfg.workerPasswordFile;
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
User = "buildbot-worker";
|
||||||
|
Group = "buildbot-worker";
|
||||||
|
WorkingDirectory = "/var/lib/buildbot-worker";
|
||||||
|
|
||||||
|
# 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";
|
||||||
|
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