Vendor buildbot
from the nixpkgs
input (nixpkgs-unstable-small
)
Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
parent
fade46ad70
commit
4b8c544db8
27
README.md
27
README.md
|
@ -25,6 +25,33 @@ separate machines. To support multiple architectures, configure them as
|
||||||
For a practical NixOS example, see
|
For a practical NixOS example, see
|
||||||
[this remote builder configuration](https://github.com/Mic92/dotfiles/blob/main/nixos/eve/modules/remote-builder.nix).
|
[this remote builder configuration](https://github.com/Mic92/dotfiles/blob/main/nixos/eve/modules/remote-builder.nix).
|
||||||
|
|
||||||
|
## Using `buildbot` with NixOS 24.05 (stable release)
|
||||||
|
|
||||||
|
The module applies custom patches that only apply to buildbot > 4.0.0. To use
|
||||||
|
buildbot-nix with NixOS 24.05, you should therefore not override the nixpkgs
|
||||||
|
input to your own stable version of buildbot-nix and leave it to the default
|
||||||
|
instead that is set to nixos-unstable-small.
|
||||||
|
|
||||||
|
So instead of using this in your flake
|
||||||
|
|
||||||
|
```
|
||||||
|
inputs = {
|
||||||
|
buildbot-nix.url = "github:nix-community/buildbot-nix";
|
||||||
|
buildbot-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Just use:
|
||||||
|
|
||||||
|
```
|
||||||
|
inputs = {
|
||||||
|
buildbot-nix.url = "github:nix-community/buildbot-nix";
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
An alternative is to point nixpkgs to your own version of nixpkgs-unstable in
|
||||||
|
case you are already using it elsewhere.
|
||||||
|
|
||||||
## Using Buildbot in Your Project
|
## Using Buildbot in Your Project
|
||||||
|
|
||||||
Buildbot-nix automatically triggers builds for your project under these
|
Buildbot-nix automatically triggers builds for your project under these
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
] ++ inputs.nixpkgs.lib.optional (inputs.treefmt-nix ? flakeModule) ./nix/treefmt/flake-module.nix;
|
] ++ inputs.nixpkgs.lib.optional (inputs.treefmt-nix ? flakeModule) ./nix/treefmt/flake-module.nix;
|
||||||
systems = [ "x86_64-linux" ];
|
systems = [ "x86_64-linux" ];
|
||||||
flake = {
|
flake = {
|
||||||
nixosModules.buildbot-master = ./nix/master.nix;
|
nixosModules.buildbot-master = import ./nix/master.nix inputs;
|
||||||
nixosModules.buildbot-worker = ./nix/worker.nix;
|
nixosModules.buildbot-worker = import ./nix/worker.nix inputs;
|
||||||
|
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
let
|
let
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{ nixpkgs, ... }:
|
||||||
{ config
|
{ config
|
||||||
, pkgs
|
, pkgs
|
||||||
, lib
|
, lib
|
||||||
|
@ -8,6 +9,7 @@ let
|
||||||
inherit (lib) mkRemovedOptionModule mkRenamedOptionModule;
|
inherit (lib) mkRemovedOptionModule mkRenamedOptionModule;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
_file = ./master.nix;
|
||||||
imports = [
|
imports = [
|
||||||
(mkRenamedOptionModule
|
(mkRenamedOptionModule
|
||||||
[
|
[
|
||||||
|
@ -57,8 +59,17 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
services.buildbot-nix.vendorBuildbot = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether to vendow `buildbot-master` from the `nixpkgs` input of the `buildbot-nix` flake.
|
||||||
|
`buildbot-nix` requires `buildbot-master` to be at least of version `4`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
services.buildbot-nix.master = {
|
services.buildbot-nix.master = {
|
||||||
enable = lib.mkEnableOption "buildbot-master";
|
enable = lib.mkEnableOption "buildbot-master";
|
||||||
|
package = lib.mkPackageOption pkgs "buildbot" { };
|
||||||
dbUrl = lib.mkOption {
|
dbUrl = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "postgresql://@/buildbot";
|
default = "postgresql://@/buildbot";
|
||||||
|
@ -263,7 +274,16 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkMerge [
|
||||||
|
(lib.mkIf config.services.buildbot-nix.vendorBuildbot {
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev:
|
||||||
|
{
|
||||||
|
buildbotPackages = prev.python3.pkgs.callPackage "${nixpkgs}/pkgs/development/tools/continuous-integration/buildbot" { };
|
||||||
|
})
|
||||||
|
];
|
||||||
|
})
|
||||||
|
(lib.mkIf cfg.enable {
|
||||||
# By default buildbot uses a normal user, which is not a good default, because
|
# By default buildbot uses a normal user, which is not a good default, because
|
||||||
# we grant normal users potentially access to other resources. Also
|
# we grant normal users potentially access to other resources. Also
|
||||||
# we don't to be able to ssh into buildbot.
|
# we don't to be able to ssh into buildbot.
|
||||||
|
@ -274,6 +294,11 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
assertions = [
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion =
|
||||||
|
lib.versionAtLeast cfg.package.version "4.0.0";
|
||||||
|
message = "`buildbot-nix` requires `buildbot` 4.0.0 or greater to function";
|
||||||
|
}
|
||||||
{
|
{
|
||||||
assertion =
|
assertion =
|
||||||
cfg.cachix.name != null -> cfg.cachix.signingKeyFile != null || cfg.cachix.authTokenFile != null;
|
cfg.cachix.name != null -> cfg.cachix.signingKeyFile != null || cfg.cachix.authTokenFile != null;
|
||||||
|
@ -384,7 +409,7 @@ in
|
||||||
in
|
in
|
||||||
"${if hasSSL then "https" else "http"}://${cfg.domain}/";
|
"${if hasSSL then "https" else "http"}://${cfg.domain}/";
|
||||||
dbUrl = config.services.buildbot-nix.master.dbUrl;
|
dbUrl = config.services.buildbot-nix.master.dbUrl;
|
||||||
package = pkgs.buildbot;
|
package = cfg.package;
|
||||||
pythonPackages = ps: [
|
pythonPackages = ps: [
|
||||||
ps.requests
|
ps.requests
|
||||||
ps.treq
|
ps.treq
|
||||||
|
@ -392,7 +417,7 @@ in
|
||||||
(ps.toPythonModule pkgs.buildbot-worker)
|
(ps.toPythonModule pkgs.buildbot-worker)
|
||||||
pkgs.buildbot-plugins.www-react
|
pkgs.buildbot-plugins.www-react
|
||||||
(pkgs.python3.pkgs.callPackage ../default.nix { })
|
(pkgs.python3.pkgs.callPackage ../default.nix { })
|
||||||
(pkgs.python3.pkgs.callPackage ./buildbot-gitea.nix { buildbot = pkgs.buildbot; })
|
(pkgs.python3.pkgs.callPackage ./buildbot-gitea.nix { buildbot = cfg.package; })
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -468,5 +493,6 @@ in
|
||||||
++ lib.optional (cfg.outputsPath != null)
|
++ lib.optional (cfg.outputsPath != null)
|
||||||
# Allow buildbot-master to write to this directory
|
# Allow buildbot-master to write to this directory
|
||||||
"d ${cfg.outputsPath} 0755 buildbot buildbot - -";
|
"d ${cfg.outputsPath} 0755 buildbot buildbot - -";
|
||||||
};
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{ ... }:
|
||||||
{ config
|
{ config
|
||||||
, pkgs
|
, pkgs
|
||||||
, lib
|
, lib
|
||||||
|
@ -10,6 +11,7 @@ let
|
||||||
python = cfg.package.pythonModule;
|
python = cfg.package.pythonModule;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
_file = ./worker.nix;
|
||||||
options = {
|
options = {
|
||||||
services.buildbot-nix.worker = {
|
services.buildbot-nix.worker = {
|
||||||
enable = lib.mkEnableOption "buildbot-worker";
|
enable = lib.mkEnableOption "buildbot-worker";
|
||||||
|
@ -86,7 +88,10 @@ in
|
||||||
|
|
||||||
# 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 = "+${config.systemd.package}/bin/systemd-run --on-active=60 ${config.systemd.package}/bin/systemctl restart buildbot-worker";
|
ExecReload = "+${config.systemd.package}/bin/systemd-run --on-active=60 ${config.systemd.package}/bin/systemctl restart buildbot-worker";
|
||||||
ExecStart = "${python.pkgs.twisted}/bin/twistd --nodaemon --pidfile= --logfile - --python ${../buildbot_nix}/worker.py";
|
ExecStart = lib.traceIf
|
||||||
|
(lib.versionOlder pkgs.buildbot-worker.version "4.0.0")
|
||||||
|
"`buildbot-nix` recommends `buildbot-worker` to be at least of version `4.0.0`"
|
||||||
|
"${python.pkgs.twisted}/bin/twistd --nodaemon --pidfile= --logfile - --python ${../buildbot_nix}/worker.py";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue