ci: add buildbot support (#1985)
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk> Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Reviewed-by: Matt Sturgeon <matt@sturgeon.me.uk> Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Approved-by: Matt Sturgeon <matt@sturgeon.me.uk> Approved-by: NAHO <90870942+trueNAHO@users.noreply.github.com> Approved-by: Daniel Thwaites <danth@danth.me>
This commit is contained in:
parent
51383904f3
commit
adc6506100
5 changed files with 83 additions and 1 deletions
1
buildbot-nix.toml
Normal file
1
buildbot-nix.toml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
attribute = "ci.buildbot"
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
inputs.flake-parts.flakeModules.partitions
|
inputs.flake-parts.flakeModules.partitions
|
||||||
./deprecation
|
./deprecation
|
||||||
./modules.nix
|
./modules.nix
|
||||||
|
./options/ci.nix
|
||||||
|
./options/testbeds.nix
|
||||||
./packages.nix
|
./packages.nix
|
||||||
./propagated-packages.nix
|
./propagated-packages.nix
|
||||||
];
|
];
|
||||||
|
|
@ -15,6 +17,7 @@
|
||||||
|
|
||||||
partitionedAttrs = lib.genAttrs [
|
partitionedAttrs = lib.genAttrs [
|
||||||
"checks"
|
"checks"
|
||||||
|
"ci"
|
||||||
"devShells"
|
"devShells"
|
||||||
"formatter"
|
"formatter"
|
||||||
] (_: "dev");
|
] (_: "dev");
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,46 @@
|
||||||
# are derivations.
|
# are derivations.
|
||||||
checks = config.packages;
|
checks = config.packages;
|
||||||
|
|
||||||
|
packages = config.testbeds;
|
||||||
|
|
||||||
# Testbeds are virtual machines based on NixOS, therefore they are
|
# Testbeds are virtual machines based on NixOS, therefore they are
|
||||||
# only available for Linux systems.
|
# only available for Linux systems.
|
||||||
packages = lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
|
testbeds = lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
|
||||||
import ../../stylix/testbed {
|
import ../../stylix/testbed {
|
||||||
inherit pkgs inputs lib;
|
inherit pkgs inputs lib;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ci.buildbot = {
|
||||||
|
packages = builtins.removeAttrs config.packages (
|
||||||
|
builtins.attrNames config.testbeds
|
||||||
|
);
|
||||||
|
# Batching testbeds by target, to avoid overwhelming buildbot
|
||||||
|
testbeds = lib.pipe config.testbeds [
|
||||||
|
(lib.mapAttrsToList (
|
||||||
|
name: testbed:
|
||||||
|
let
|
||||||
|
# name is formatted as `testbed:target:variant` e.g. `testbed:alacritty:dark`
|
||||||
|
splitName = lib.splitString ":" name;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
target = builtins.elemAt splitName 1;
|
||||||
|
variant = builtins.elemAt splitName 2;
|
||||||
|
inherit testbed;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
(builtins.groupBy (entry: entry.target))
|
||||||
|
(lib.mapAttrs (_: builtins.groupBy (entry: entry.variant)))
|
||||||
|
(lib.mapAttrs (
|
||||||
|
_:
|
||||||
|
lib.mapAttrs (
|
||||||
|
_: entries:
|
||||||
|
assert lib.length entries == 1;
|
||||||
|
(lib.head entries).testbed
|
||||||
|
)
|
||||||
|
))
|
||||||
|
(lib.mapAttrs (target: pkgs.linkFarm "testbeds-${target}"))
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
flake/options/ci.nix
Normal file
35
flake/options/ci.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
{ lib, config, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) types;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
perSystem.options.ci.buildbot = lib.mkOption {
|
||||||
|
type = types.lazyAttrsOf types.raw;
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
A set of tests for [buildbot] to run.
|
||||||
|
[buildbot]: https://buildbot.nix-community.org
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
flake = {
|
||||||
|
# top-level CI option
|
||||||
|
#
|
||||||
|
# NOTE:
|
||||||
|
# This must be an actual option, NOT a set of options.
|
||||||
|
# Otherwise, flake partitions will not be lazy.
|
||||||
|
options.ci = lib.mkOption {
|
||||||
|
type = types.lazyAttrsOf (types.lazyAttrsOf types.raw);
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Outputs related to CI.
|
||||||
|
Usually defined via the `perSystem.ci` options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# Transpose per-system CI outputs to the top-level
|
||||||
|
config.ci.buildbot = lib.mapAttrs (
|
||||||
|
_: sysCfg: sysCfg.ci.buildbot
|
||||||
|
) config.allSystems;
|
||||||
|
};
|
||||||
|
}
|
||||||
9
flake/options/testbeds.nix
Normal file
9
flake/options/testbeds.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
perSystem.options.testbeds = lib.mkOption {
|
||||||
|
internal = true;
|
||||||
|
type = lib.types.lazyAttrsOf lib.types.package;
|
||||||
|
default = { };
|
||||||
|
description = "Testbeds for Stylix.";
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue