1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00

tests: test per-user home.useUserPackages

This commit is contained in:
Matt Schreiber 2025-03-16 09:36:11 -04:00
parent 61c4772096
commit 634172f673
No known key found for this signature in database
3 changed files with 16 additions and 1 deletions

View file

@ -4,7 +4,7 @@
name = "nixos-basics";
meta.maintainers = [ pkgs.lib.maintainers.rycee ];
nodes.machine = { config, ... }:
nodes.machine = { config, pkgs, ... }:
let inherit (config.home-manager.users) bob;
in {
imports = [ ../../../nixos ]; # Import the HM NixOS module.
@ -38,10 +38,13 @@
uid = 1000;
};
home-manager.useUserPackages = true;
home-manager.users = let
common = {
home.stateVersion = "24.11";
home.file.test.text = "testfile";
home.packages = [ pkgs.hello ];
# Enable a light-weight systemd service.
services.pueue.enable = true;
};
@ -54,6 +57,7 @@
home.stateVersion = "24.11";
home.username = lib.mkForce name;
home.homeDirectory = lib.mkForce "/var/tmp/hm/home/bob";
home.useUserPackages = false;
};
};
};
@ -142,6 +146,9 @@
expected = "testfile"
assert actual == expected, f"expected {path} to contain {expected}, but got {actual}"
with subtest(f"Command from `home.packages` (user {user})"):
succeed_as_user(user, "hello")
with subtest(f"Pueue service (user {user})"):
with user_login(machine, user, "${password}"):
actual = succeed_as_user(user, "pueue status")

View file

@ -2,4 +2,5 @@
home-session-path = ./session-path.nix;
home-session-search-variables = ./session-search-variables.nix;
home-session-variables = ./session-variables.nix;
home-use-user-packages = ./use-user-packages.nix;
}

View file

@ -0,0 +1,7 @@
{
home.useUserPackages = true;
test.asserts.warnings.expected = [
"You have enabled `home.useUserPackages`, but this option has no effect outside of NixOS configurations."
];
}