mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-31 22:51:22 +00:00
e538e00404
It is quite complicated to test services using the test-driver when declaring user services with `systemd.user.services` such as many X11-based services like `xautolock.service`. This change adds an optional `$user` parameter to each systemd-related function in the test-driver and runs `systemctl --user` commands using `su -l $user -c ...` and sets the `XDG_RUNTIME_DIR` variable accordingly and a new function named `systemctl` which is able to run a systemd command with or without a specified user. The change can be confirmed with a simple VM declaration like this: ``` import ./nixos/tests/make-test.nix ({ pkgs, lib }: with lib; { name = "systemd-user-test"; nodes.machine = { imports = [ ./nixos/tests/common/user-account.nix ]; services.xserver.enable = true; services.xserver.displayManager.auto.enable = true; services.xserver.displayManager.auto.user = "bob"; services.xserver.xautolock.enable = true; }; testScript = '' $machine->start; $machine->waitForX; $machine->waitForUnit("xautolock.service", "bob"); $machine->stopJob("xautolock.service", "bob"); $machine->startJob("xautolock.service", "bob"); $machine->systemctl("list-jobs --no-pager", "bob"); $machine->systemctl("show 'xautolock.service' --no-pager", "bob"); ''; }) ``` |
||
---|---|---|
.. | ||
doc/manual | ||
lib | ||
maintainers | ||
modules | ||
tests | ||
COPYING | ||
default.nix | ||
README | ||
release-combined.nix | ||
release-small.nix | ||
release.nix |
*** NixOS *** NixOS is a Linux distribution based on the purely functional package management system Nix. More information can be found at http://nixos.org/nixos and in the manual in doc/manual.