nixos/tests/seatd: init

This commit is contained in:
sinanmohd 2023-08-25 10:59:57 +05:30 committed by tomf
parent 9796cbb021
commit aa0b9d2780
3 changed files with 55 additions and 0 deletions

View file

@ -742,6 +742,7 @@ in {
sddm = handleTest ./sddm.nix {}; sddm = handleTest ./sddm.nix {};
seafile = handleTest ./seafile.nix {}; seafile = handleTest ./seafile.nix {};
searx = handleTest ./searx.nix {}; searx = handleTest ./searx.nix {};
seatd = handleTest ./seatd.nix {};
service-runner = handleTest ./service-runner.nix {}; service-runner = handleTest ./service-runner.nix {};
sftpgo = runTest ./sftpgo.nix; sftpgo = runTest ./sftpgo.nix;
sfxr-qt = handleTest ./sfxr-qt.nix {}; sfxr-qt = handleTest ./sfxr-qt.nix {};

51
nixos/tests/seatd.nix Normal file
View file

@ -0,0 +1,51 @@
import ./make-test-python.nix ({ pkgs, lib, ... }:
let
seatd-test = pkgs.writeShellApplication {
name = "seatd-client-pid";
text = ''
journalctl -u seatd --no-pager -b | while read -r line; do
case "$line" in
*"New client connected"*)
line="''${line##*pid: }"
pid="''${line%%,*}"
;;
*"Opened client"*)
echo "$pid"
exit
esac
done;
'';
};
in
{
name = "seatd";
meta.maintainers = with lib.maintainers; [ sinanmohd ];
nodes.machine = { ... }: {
imports = [ ./common/user-account.nix ];
services.getty.autologinUser = "alice";
users.users.alice.extraGroups = [ "seat" "wheel" ];
fonts.enableDefaultPackages = true;
environment.systemPackages = with pkgs; [
dwl
foot
seatd-test
];
programs.bash.loginShellInit = ''
[ "$(tty)" = "/dev/tty1" ] &&
dwl -s 'foot touch /tmp/foot_started'
'';
hardware.opengl.enable = true;
virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
services.seatd.enable = true;
};
testScript = ''
machine.wait_for_file("/tmp/foot_started")
machine.succeed("test $(seatd-client-pid) = $(pgrep dwl)")
'';
})

View file

@ -6,6 +6,7 @@
, scdoc , scdoc
, stdenv , stdenv
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd , systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
, nixosTests
}: }:
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
@ -40,6 +41,8 @@ stdenv.mkDerivation (finalAttrs: {
"-Dserver=enabled" "-Dserver=enabled"
]; ];
passthru.tests.basic = nixosTests.seatd;
meta = { meta = {
description = "A minimal seat management daemon, and a universal seat management library"; description = "A minimal seat management daemon, and a universal seat management library";
changelog = "https://git.sr.ht/~kennylevinsen/seatd/refs/${finalAttrs.version}"; changelog = "https://git.sr.ht/~kennylevinsen/seatd/refs/${finalAttrs.version}";