use nixos options instead of nixpkgs overlay

The overlay will break if buildbot in unstable will change it's python
override in nixpkgs.
This will happen in the next release when sqlalchemy will be update.

Also I have at least three installations where I share nixpkgs instances
across multiple nixos configuration for performance reasons,
where I cannot use overlays defined in a NixOS module.
This commit is contained in:
Jörg Thalheim 2024-07-13 08:34:04 +02:00 committed by mergify[bot]
parent 6efd536381
commit e8a88f8f15
3 changed files with 37 additions and 36 deletions

View file

@ -20,8 +20,18 @@
] ++ 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 = import ./nix/master.nix inputs; nixosModules.buildbot-master.imports = [
nixosModules.buildbot-worker = import ./nix/worker.nix inputs; ./nix/master.nix
({ pkgs, ... }: {
services.buildbot-nix.master.buildbotNixpkgs = lib.mkDefault inputs.nixpkgs.legacyPackages.${pkgs.hostPlatform.system};
})
];
nixosModules.buildbot-worker.imports = [
./nix/worker.nix
({ pkgs, ... }: {
services.buildbot-nix.worker.package = lib.mkDefault inputs.nixpkgs.legacyPackages.${pkgs.hostPlatform.system}.buildbot-worker;
})
];
nixosConfigurations = nixosConfigurations =
let let

View file

@ -1,4 +1,3 @@
{ nixpkgs, ... }:
{ config { config
, pkgs , pkgs
, lib , lib
@ -9,7 +8,6 @@ let
inherit (lib) mkRemovedOptionModule mkRenamedOptionModule; inherit (lib) mkRemovedOptionModule mkRenamedOptionModule;
in in
{ {
_file = ./master.nix;
imports = [ imports = [
(mkRenamedOptionModule (mkRenamedOptionModule
[ [
@ -59,17 +57,8 @@ 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";
@ -266,6 +255,11 @@ in
''; '';
}; };
buildbotNixpkgs = lib.mkOption {
type = lib.types.raw;
description = "Nixpkgs to use for buildbot packages";
};
outputsPath = lib.mkOption { outputsPath = lib.mkOption {
type = lib.types.nullOr lib.types.path; type = lib.types.nullOr lib.types.path;
description = "Path where we store the latest build store paths names for nix attributes as text files. This path will be exposed via nginx at \${domain}/nix-outputs"; description = "Path where we store the latest build store paths names for nix attributes as text files. This path will be exposed via nginx at \${domain}/nix-outputs";
@ -275,14 +269,6 @@ in
}; };
}; };
config = lib.mkMerge [ 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 { (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
@ -296,8 +282,12 @@ in
assertions = [ assertions = [
{ {
assertion = assertion =
lib.versionAtLeast cfg.package.version "4.0.0"; lib.versionAtLeast cfg.buildbotNixpkgs.buildbot.version "4.0.0";
message = "`buildbot-nix` requires `buildbot` 4.0.0 or greater to function"; message = ''
`buildbot-nix` requires `buildbot` 4.0.0 or greater to function.
Set services.buildbot-nix.master.buildbotNixpkgs to a nixpkgs with buildbot >= 4.0.0,
i.e. nixpkgs-unstable.
'';
} }
{ {
assertion = assertion =
@ -409,21 +399,20 @@ 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 =
cfg.package.overrideAttrs (old: { package = cfg.buildbotNixpkgs.buildbot.overrideAttrs (old: {
patches = patches = old.patches ++ [ ./0001-Support-per-installation-tokens-in-GithubStatusPush-.patch ];
old.patches ++ [
./0001-Support-per-installation-tokens-in-GithubStatusPush-.patch #;
];
}); });
pythonPackages = ps: [ pythonPackages = ps: [
ps.requests ps.requests
ps.treq ps.treq
ps.psycopg2 ps.psycopg2
(ps.toPythonModule pkgs.buildbot-worker) (ps.toPythonModule cfg.buildbotNixpkgs.buildbot-worker)
pkgs.buildbot-plugins.www-react cfg.buildbotNixpkgs.buildbot-plugins.www-react
(pkgs.python3.pkgs.callPackage ../default.nix { }) (cfg.buildbotNixpkgs.python3.pkgs.callPackage ../default.nix { })
(pkgs.python3.pkgs.callPackage ./buildbot-gitea.nix { buildbot = cfg.package; }) (cfg.buildbotNixpkgs.python3.pkgs.callPackage ./buildbot-gitea.nix {
inherit (cfg.buildbotNixpkgs) buildbot;
})
]; ];
}; };

View file

@ -1,4 +1,3 @@
{ ... }:
{ config { config
, pkgs , pkgs
, lib , lib
@ -90,7 +89,10 @@ in
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 = lib.traceIf ExecStart = lib.traceIf
(lib.versionOlder pkgs.buildbot-worker.version "4.0.0") (lib.versionOlder pkgs.buildbot-worker.version "4.0.0")
"`buildbot-nix` recommends `buildbot-worker` to be at least of version `4.0.0`" ''
`buildbot-nix` recommends `buildbot-worker` to be at least of version `4.0.0`.
Consider upgrading by setting `services.buildbot-nix.worker.package` i.e. from nixpkgs-unstable.
''
"${python.pkgs.twisted}/bin/twistd --nodaemon --pidfile= --logfile - --python ${../buildbot_nix}/worker.py"; "${python.pkgs.twisted}/bin/twistd --nodaemon --pidfile= --logfile - --python ${../buildbot_nix}/worker.py";
}; };
}; };