1
0
Fork 0
mirror of https://github.com/zhaofengli/attic.git synced 2024-12-14 11:57:30 +00:00
attic/flake/integration-tests.nix

61 lines
1.5 KiB
Nix
Raw Normal View History

{ lib, flake-parts-lib, inputs, self, ... }:
let
inherit (lib)
mkOption
types
;
inherit (flake-parts-lib)
mkPerSystemOption
;
in
{
options = {
perSystem = mkPerSystemOption {
options.attic.integration-tests = {
nixpkgsArgs = mkOption {
type = types.attrsOf types.anything;
default = {};
};
tests = mkOption {
type = types.attrsOf types.package;
default = {};
};
stableTests = mkOption {
type = types.attrsOf types.package;
default = {};
};
};
};
};
config = {
perSystem = { self', pkgs, config, system, ... }: let
cfg = config.attic.integration-tests;
vmPkgs = import inputs.nixpkgs ({
inherit system;
overlays = [ self.overlays.default ];
} // cfg.nixpkgsArgs);
vmPkgsStable = import inputs.nixpkgs-stable ({
inherit system;
overlays = [ self.overlays.default ];
} // cfg.nixpkgsArgs);
makeIntegrationTests = pkgs: import ../integration-tests {
inherit pkgs;
flake = self;
};
in {
attic.integration-tests = {
tests = makeIntegrationTests vmPkgs;
stableTests = makeIntegrationTests vmPkgsStable;
};
checks = let
tests = cfg.tests;
stableTests = lib.mapAttrs' (name: lib.nameValuePair "stable-${name}") cfg.stableTests;
in lib.optionalAttrs pkgs.stdenv.isLinux (tests // stableTests);
};
};
}