add darwin test configurations (#525)

This commit is contained in:
zowoq 2024-10-03 00:51:03 +10:00 committed by GitHub
parent ce661d208f
commit 8cf7a278fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 90 additions and 0 deletions

17
dev/darwin-checks.nix Normal file
View File

@ -0,0 +1,17 @@
{
inputs,
prefix,
self,
pkgs,
}:
let
lib = pkgs.lib;
darwinConfigurations = import ./darwin-test-configurations.nix { inherit inputs self pkgs; };
darwinChecks = lib.mapAttrs' (name: value: {
name = "${prefix}-${name}";
value = value.config.system.build.toplevel;
}) (lib.filterAttrs (_name: value: value != null) darwinConfigurations);
in
darwinChecks

View File

@ -0,0 +1,67 @@
# We use the darwinConfigurations to test all the modules below.
#
# This is not optimal, but it gets the job done
{
inputs,
self,
pkgs,
}:
let
lib = pkgs.lib;
darwinSystem =
args: import "${toString inputs.nix-darwin}/eval-config.nix" ({ inherit lib; } // args);
# some example configuration to make it eval
dummy =
{ config, ... }:
{
networking.hostName = "example-common";
system.stateVersion = 5;
# Don't reinstantiate nixpkgs for every eval.
# Also important to have nixpkgs config which allows for some required insecure packages
nixpkgs = {
inherit pkgs;
};
};
in
{
# General
example-common = darwinSystem {
modules = [
dummy
self.darwinModules.common
];
};
example-server = darwinSystem {
modules = [
dummy
self.darwinModules.server
];
};
example-desktop = darwinSystem {
modules = [
dummy
self.darwinModules.desktop
];
};
example-mixins-terminfo = darwinSystem {
modules = [
dummy
self.darwinModules.mixins-terminfo
];
};
example-mixins-telegraf = darwinSystem {
modules = [
dummy
self.darwinModules.mixins-telegraf
];
};
example-mixins-trusted-nix-caches = darwinSystem {
modules = [
dummy
self.darwinModules.mixins-trusted-nix-caches
];
};
}

View File

@ -60,6 +60,12 @@
inherit (self') formatter;
}
// packages
// (lib.optionalAttrs (pkgs.stdenv.hostPlatform.system == "aarch64-darwin") (
import ./dev/darwin-checks.nix {
inherit inputs self pkgs;
prefix = "darwin";
}
))
// (lib.optionalAttrs isLinux (
import ./dev/checks.nix {
inherit self pkgs;