feat: unit tests

This commit is contained in:
Ryan Yin
2024-03-13 14:47:36 +08:00
parent be963c0642
commit fff6ad6bff
17 changed files with 142 additions and 59 deletions

View File

@@ -0,0 +1,15 @@
{
myvars,
lib,
}: let
username = myvars.username;
hosts = [
"ai-hyprland"
"ai-i3"
"shoukei-hyprland"
"shoukei-i3"
"ruby"
"k3s-prod-1-master-1"
];
in
lib.genAttrs hosts (_: "/home/${username}")

View File

@@ -0,0 +1,20 @@
{
myvars,
lib,
outputs,
}: let
username = myvars.username;
hosts = [
"ai-hyprland"
"ai-i3"
"shoukei-hyprland"
"shoukei-i3"
"ruby"
"k3s-prod-1-master-1"
];
in
lib.genAttrs
hosts
(
name: outputs.nixosConfigurations.${name}.config.home-manager.users.${username}.home.homeDirectory
)

View File

@@ -0,0 +1,17 @@
{
lib,
outputs,
}: let
specialExpected = {
"ai-hyprland" = "ai";
"ai-i3" = "ai";
"shoukei-hyprland" = "shoukei";
"shoukei-i3" = "shoukei";
};
specialHostNames = builtins.attrNames specialExpected;
otherHosts = builtins.removeAttrs outputs.nixosConfigurations specialHostNames;
otherHostsNames = builtins.attrNames otherHosts;
# other hosts's hostName is the same as the nixosConfigurations name
otherExpected = lib.genAttrs otherHostsNames (name: name);
in (specialExpected // otherExpected)

View File

@@ -0,0 +1,9 @@
{
lib,
outputs,
}:
lib.genAttrs
(builtins.attrNames outputs.nixosConfigurations)
(
name: outputs.nixosConfigurations.${name}.config.networking.hostName
)