Merge pull request #105 from ryan4yin/add-tests-kernel

feat(tests): add simple kernel test
This commit is contained in:
Ryan Yin
2024-03-25 00:29:30 +08:00
committed by GitHub
13 changed files with 47 additions and 12 deletions

View File

@@ -37,4 +37,5 @@ jobs:
- name: Run Nix Flake Eval Tests
run: |
echo 'Flake Eval Tests'
nix eval .#checks --show-trace --print-build-logs --verbose
nix eval .#evalTests --show-trace --print-build-logs --verbose

View File

@@ -3,9 +3,7 @@
fileSystems."/run/media/nixos_k3s" = {
device = "/dev/disk/by-label/NIXOS_K3S";
fsType = "vfat";
mountOptions = [
"ro"
];
options = ["ro"];
};
disko.devices = {

View File

@@ -9,10 +9,10 @@
tags,
ssh-user,
genSpecialArgs,
specialArgs ? (genSpecialArgs system),
...
}: let
inherit (inputs) home-manager;
specialArgs = genSpecialArgs system;
in
{name, ...}: {
deployment = {

View File

@@ -6,10 +6,10 @@
myvars,
system,
genSpecialArgs,
specialArgs ? (genSpecialArgs system),
...
}: let
inherit (inputs) nixpkgs home-manager nix-darwin;
specialArgs = genSpecialArgs system;
in
nix-darwin.lib.darwinSystem {
inherit system specialArgs;

View File

@@ -5,11 +5,11 @@
genSpecialArgs,
nixos-modules,
home-modules ? [],
specialArgs ? (genSpecialArgs system),
myvars,
...
}: let
inherit (inputs) nixpkgs home-manager nixos-generators;
specialArgs = genSpecialArgs system;
in
nixpkgs.lib.nixosSystem {
inherit system specialArgs;

View File

@@ -0,0 +1,8 @@
{
lib,
outputs,
}: let
hostsNames = builtins.attrNames outputs.nixosConfigurations;
expected = lib.genAttrs hostsNames (_: true);
in
expected

View File

@@ -0,0 +1,11 @@
{
lib,
outputs,
}:
lib.genAttrs
(builtins.attrNames outputs.nixosConfigurations)
(
# test only if kernelPackages is set, to avoid build the kernel.
# name: outputs.nixosConfigurations.${name}.config.boot.kernelPackages.kernel.system
name: outputs.nixosConfigurations.${name}.config.boot.kernelPackages != null
)

View File

@@ -53,9 +53,6 @@ in {
# Add attribute sets into outputs, for debugging
debugAttrs = {inherit nixosSystems darwinSystems allSystems allSystemNames;};
# Eval Tests for all NixOS systems.
evalTests = lib.lists.all (it: it.evalTests == {}) allSystemValues;
# NixOS Hosts
nixosConfigurations =
lib.attrsets.mergeAttrsList (map (it: it.nixosConfigurations or {}) nixosSystemValues);
@@ -90,8 +87,14 @@ in {
system: allSystems.${system}.packages or {}
);
# Eval Tests for all NixOS & darwin systems.
evalTests = lib.lists.all (it: it.evalTests == {}) allSystemValues;
checks = forAllSystems (
system: {
# eval-tests per system
eval-tests = allSystems.${system}.evalTests == {};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = mylib.relativeToRoot ".";
hooks = {

View File

@@ -20,7 +20,6 @@
# common
"secrets/nixos.nix"
"modules/nixos/server/server.nix"
"modules/nixos/server/proxmox-hardware-configuration.nix"
# host specific
"hosts/k8s/${name}"
])

View File

@@ -20,7 +20,6 @@
# common
"secrets/nixos.nix"
"modules/nixos/server/server.nix"
"modules/nixos/server/proxmox-hardware-configuration.nix"
# host specific
"hosts/k8s/${name}"
])

View File

@@ -20,7 +20,6 @@
# common
"secrets/nixos.nix"
"modules/nixos/server/server.nix"
"modules/nixos/server/proxmox-hardware-configuration.nix"
# host specific
"hosts/k8s/${name}"
])

View File

@@ -0,0 +1,8 @@
{
lib,
outputs,
}: let
hostsNames = builtins.attrNames outputs.nixosConfigurations;
expected = lib.genAttrs hostsNames (_: "x86_64-linux");
in
expected

View File

@@ -0,0 +1,9 @@
{
lib,
outputs,
}:
lib.genAttrs
(builtins.attrNames outputs.nixosConfigurations)
(
name: outputs.nixosConfigurations.${name}.config.boot.kernelPackages.kernel.system
)