Skip to content

[Backport nixos-25.05] flake: add ci.buildbot output #3419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions buildbot-nix.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
attribute = "ci.buildbot"
43 changes: 43 additions & 0 deletions flake/ci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{ lib, config, ... }:
let
inherit (lib)
mapAttrs
types
;

buildbotOpt = lib.mkOption {
type = types.lazyAttrsOf types.package;
default = { };
description = ''
A set of tests for [buildbot] to run.

[buildbot]: https://buildbot.nix-community.org
'';
};
in
{
perSystem = {
# Declare per-system CI options
options.ci = {
buildbot = buildbotOpt;
};
};

flake = {
# Declare top-level CI options
options.ci = {
buildbot = lib.mkOption {
type = types.lazyAttrsOf buildbotOpt.type;
default = { };
description = ''
See `perSystem.ci.buildbot` for description and examples.
'';
};
};

# Transpose per-system CI outputs to the top-level
config.ci = {
buildbot = mapAttrs (_: sysCfg: sysCfg.ci.buildbot) config.allSystems;
};
};
}
2 changes: 2 additions & 0 deletions flake/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{
imports = [
./flake-modules
./ci.nix
./lib.nix
./legacy-packages.nix
./nixvim-configurations.nix
Expand All @@ -31,6 +32,7 @@

# Specify which outputs are defined by which partitions
partitionedAttrs = {
ci = "dev";
checks = "dev";
devShells = "dev";
formatter = "dev";
Expand Down
1 change: 1 addition & 0 deletions flake/dev/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
{
name = "checks";
help = "Run all nixvim checks";
# TODO: run tests from the `ci` flake output too?
command = ''
echo "=> Running all nixvim checks..."

Expand Down
4 changes: 4 additions & 0 deletions flake/dev/package-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
{
# Test that all packages build fine when running `nix flake check`.
checks = config.packages;

# Test that all packages build when running buildbot
# TODO: only test the docs on x86_64-linux
ci.buildbot = config.packages;
};
}
7 changes: 7 additions & 0 deletions flake/dev/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@
perSystem =
{ pkgs, ... }:
{
# TODO: consider whether all these tests are needed in the `checks` output
checks = pkgs.callPackages ../../tests {
inherit helpers self;
};

# TODO: consider whether all these tests are needed to be built by buildbot
ci.buildbot = pkgs.callPackages ../../tests {
inherit helpers self;
allSystems = false;
};
};
}
14 changes: 12 additions & 2 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
linkFarm,
self, # The flake instance
system ? pkgs.stdenv.hostPlatform.system,
allSystems ? true,
}:
let
autoArgs = pkgs // {
Expand All @@ -31,8 +32,15 @@ let
callTests = lib.callPackagesWith autoArgs;

selfPackages = self.packages.${system};

# For tests that CI should only build on one system,
# This is true when on that system.
#
# TODO: consider refactoring tests/default.nix so that some tests are
# defined by it, while others are defined elsewhere...
buildForThisSystem = allSystems || system == "x86_64-linux";
in
{
lib.optionalAttrs buildForThisSystem {
extra-args-tests = callTest ./extra-args.nix { };
extend = callTest ./extend.nix { };
extra-files = callTest ./extra-files.nix { };
Expand All @@ -47,10 +55,12 @@ in
lsp-all-servers = callTest ./lsp-servers.nix { };
}
# Expose some tests from the docs as flake-checks too
// lib.optionalAttrs (selfPackages ? docs) {
// lib.optionalAttrs (selfPackages ? docs && buildForThisSystem) {
# Individual tests can be run using: nix build .#docs.user-configs.tests.<test>
docs-user-configs = linkFarm "user-configs-tests" selfPackages.docs.user-configs.tests;
}

# These are always built on all systems, even when `allSystems = false`
// callTests ./platforms { }
# Tests generated from ./test-sources
# Grouped as a number of link-farms in the form { test-1, test-2, ... test-N }
Expand Down