mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-18 07:24:10 +01:00
Merge pull request #105 from ryan4yin/add-tests-kernel
feat(tests): add simple kernel test
This commit is contained in:
1
.github/workflows/flake_evaltests.yml
vendored
1
.github/workflows/flake_evaltests.yml
vendored
@@ -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
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
fileSystems."/run/media/nixos_k3s" = {
|
||||
device = "/dev/disk/by-label/NIXOS_K3S";
|
||||
fsType = "vfat";
|
||||
mountOptions = [
|
||||
"ro"
|
||||
];
|
||||
options = ["ro"];
|
||||
};
|
||||
|
||||
disko.devices = {
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
tags,
|
||||
ssh-user,
|
||||
genSpecialArgs,
|
||||
specialArgs ? (genSpecialArgs system),
|
||||
...
|
||||
}: let
|
||||
inherit (inputs) home-manager;
|
||||
specialArgs = genSpecialArgs system;
|
||||
in
|
||||
{name, ...}: {
|
||||
deployment = {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
8
outputs/aarch64-linux/tests/kernel/expected.nix
Normal file
8
outputs/aarch64-linux/tests/kernel/expected.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
lib,
|
||||
outputs,
|
||||
}: let
|
||||
hostsNames = builtins.attrNames outputs.nixosConfigurations;
|
||||
expected = lib.genAttrs hostsNames (_: true);
|
||||
in
|
||||
expected
|
||||
11
outputs/aarch64-linux/tests/kernel/expr.nix
Normal file
11
outputs/aarch64-linux/tests/kernel/expr.nix
Normal 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
|
||||
)
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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}"
|
||||
])
|
||||
|
||||
@@ -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}"
|
||||
])
|
||||
|
||||
@@ -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}"
|
||||
])
|
||||
|
||||
8
outputs/x86_64-linux/tests/kernel/expected.nix
Normal file
8
outputs/x86_64-linux/tests/kernel/expected.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
lib,
|
||||
outputs,
|
||||
}: let
|
||||
hostsNames = builtins.attrNames outputs.nixosConfigurations;
|
||||
expected = lib.genAttrs hostsNames (_: "x86_64-linux");
|
||||
in
|
||||
expected
|
||||
9
outputs/x86_64-linux/tests/kernel/expr.nix
Normal file
9
outputs/x86_64-linux/tests/kernel/expr.nix
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
lib,
|
||||
outputs,
|
||||
}:
|
||||
lib.genAttrs
|
||||
(builtins.attrNames outputs.nixosConfigurations)
|
||||
(
|
||||
name: outputs.nixosConfigurations.${name}.config.boot.kernelPackages.kernel.system
|
||||
)
|
||||
Reference in New Issue
Block a user