Skip to content

Commit

Permalink
refactor(tests): better handle test user naming
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo committed Dec 11, 2024
1 parent 8e66653 commit 63cf4e4
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 43 deletions.
1 change: 1 addition & 0 deletions tests/common.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ pkgs, ... }:

{
catppuccin = {
enable = true;
Expand Down
76 changes: 40 additions & 36 deletions tests/darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,45 @@
modules = [
./home.nix

{
home = {
homeDirectory = "/Users/test";
};

i18n.inputMethod.enabled = lib.mkVMOverride null;

programs = {
cava.enable = lib.mkVMOverride false; # NOTE: this may actually work on darwin, but the package is currently not supported
foot.enable = lib.mkVMOverride false;
fuzzel.enable = lib.mkVMOverride false;
hyprlock.enable = lib.mkVMOverride false;
imv.enable = lib.mkVMOverride false;
mpv.enable = lib.mkVMOverride false; # NOTE: same as cava, but `mpv` fails to build currently
obs-studio.enable = lib.mkVMOverride false;
rio.enable = lib.mkVMOverride false; # marked as broken
rofi.enable = lib.mkVMOverride false;
spotify-player.enable = lib.mkVMOverride false; # NOTE: same as mpv
swaylock.enable = lib.mkVMOverride false;
tofi.enable = lib.mkVMOverride false;
waybar.enable = lib.mkVMOverride false;
};

qt.enable = lib.mkVMOverride false; # NOTE: same as cava

services = {
dunst.enable = lib.mkVMOverride false;
mako.enable = lib.mkVMOverride false;
polybar.enable = lib.mkVMOverride false;
};

wayland.windowManager = {
hyprland.enable = lib.mkVMOverride false;
sway.enable = lib.mkVMOverride false;
};
}
(
{ config, ... }:

{
home = {
homeDirectory = "/Users/${config.home.username}";
};

i18n.inputMethod.enabled = lib.mkVMOverride null;

programs = {
cava.enable = lib.mkVMOverride false; # NOTE: this may actually work on darwin, but the package is currently not supported
foot.enable = lib.mkVMOverride false;
fuzzel.enable = lib.mkVMOverride false;
hyprlock.enable = lib.mkVMOverride false;
imv.enable = lib.mkVMOverride false;
mpv.enable = lib.mkVMOverride false; # NOTE: same as cava, but `mpv` fails to build currently
obs-studio.enable = lib.mkVMOverride false;
rio.enable = lib.mkVMOverride false; # marked as broken
rofi.enable = lib.mkVMOverride false;
spotify-player.enable = lib.mkVMOverride false; # NOTE: same as mpv
swaylock.enable = lib.mkVMOverride false;
tofi.enable = lib.mkVMOverride false;
waybar.enable = lib.mkVMOverride false;
};

qt.enable = lib.mkVMOverride false; # NOTE: same as cava

services = {
dunst.enable = lib.mkVMOverride false;
mako.enable = lib.mkVMOverride false;
polybar.enable = lib.mkVMOverride false;
};

wayland.windowManager = {
hyprland.enable = lib.mkVMOverride false;
sway.enable = lib.mkVMOverride false;
};
}
)
];
}).activationPackage
3 changes: 2 additions & 1 deletion tests/home.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib, ... }:

{
imports = [
../modules/home-manager
Expand All @@ -8,7 +9,7 @@
xdg.enable = true;

home = {
username = "test";
username = lib.fileContents ./username.txt;
stateVersion = lib.mkDefault "23.11";
};

Expand Down
22 changes: 16 additions & 6 deletions tests/nixos.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{ testers, home-manager }:
{
lib,
testers,
home-manager,
}:

let
userName = lib.fileContents ./username.txt;
in

testers.runNixOSTest {
name = "module-test";
name = "catppuccin-nix";

nodes.machine =
{ lib, pkgs, ... }:

{
imports = [
home-manager.nixosModules.default
Expand Down Expand Up @@ -32,9 +41,8 @@ testers.runNixOSTest {
type = "fcitx5";
};

users.users.test = {
users.users.${userName} = {
isNormalUser = true;
home = "/home/test";
uid = 1000;
};

Expand All @@ -43,16 +51,18 @@ testers.runNixOSTest {
writableStore = true;
};

home-manager.users.test = {
home-manager.users.${userName} = {
imports = [ ./home.nix ];
};
};

testScript =
{ nodes, ... }:

let
user = nodes.machine.users.users.test;
user = nodes.machine.users.users.${userName};
in

''
start_all()
Expand Down
1 change: 1 addition & 0 deletions tests/username.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pepperjack

0 comments on commit 63cf4e4

Please sign in to comment.