Merge pull request #158178 from j0hax/retroarch-wm

This commit is contained in:
Sandro 2022-02-10 01:23:37 +01:00 committed by GitHub
commit 6a4dea5ffc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 91 additions and 1 deletions

View file

@ -19,7 +19,7 @@ in
# E.g., if Plasma 5 is enabled, it supersedes xterm.
imports = [
./none.nix ./xterm.nix ./xfce.nix ./plasma5.nix ./lumina.nix
./lxqt.nix ./enlightenment.nix ./gnome.nix ./kodi.nix
./lxqt.nix ./enlightenment.nix ./gnome.nix ./retroarch.nix ./kodi.nix
./mate.nix ./pantheon.nix ./surf-display.nix ./cde.nix
./cinnamon.nix
];

View file

@ -0,0 +1,40 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.xserver.desktopManager.retroarch;
in {
options.services.xserver.desktopManager.retroarch = {
enable = mkEnableOption "RetroArch";
package = mkOption {
type = types.package;
default = pkgs.retroarch;
defaultText = literalExpression "pkgs.retroarch";
example = literalExpression "pkgs.retroarch-full";
description = "RetroArch package to use.";
};
extraArgs = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "--verbose" "--host" ];
description = "Extra arguments to pass to RetroArch.";
};
};
config = mkIf cfg.enable {
services.xserver.desktopManager.session = [{
name = "RetroArch";
start = ''
${cfg.package}/bin/retroarch -f ${escapeShellArgs cfg.extraArgs} &
waitPID=$!
'';
}];
environment.systemPackages = [ cfg.package ];
};
meta.maintainers = with maintainers; [ j0hax ];
}

View file

@ -441,6 +441,7 @@ in
resolv = handleTest ./resolv.nix {};
restartByActivationScript = handleTest ./restart-by-activation-script.nix {};
restic = handleTest ./restic.nix {};
retroarch = handleTest ./retroarch.nix {};
riak = handleTest ./riak.nix {};
robustirc-bridge = handleTest ./robustirc-bridge.nix {};
roundcube = handleTest ./roundcube.nix {};

49
nixos/tests/retroarch.nix Normal file
View file

@ -0,0 +1,49 @@
import ./make-test-python.nix ({ pkgs, ... }:
{
name = "retroarch";
meta = with pkgs.lib.maintainers; { maintainers = [ j0hax ]; };
machine = { ... }:
{
imports = [ ./common/user-account.nix ];
services.xserver.enable = true;
services.xserver.desktopManager.retroarch = {
enable = true;
package = pkgs.retroarchFull;
};
services.xserver.displayManager = {
sddm.enable = true;
defaultSession = "RetroArch";
autoLogin = {
enable = true;
user = "alice";
};
};
};
testScript = { nodes, ... }:
let
user = nodes.machine.config.users.users.alice;
xdo = "${pkgs.xdotool}/bin/xdotool";
in ''
with subtest("Wait for login"):
start_all()
machine.wait_for_file("${user.home}/.Xauthority")
machine.succeed("xauth merge ${user.home}/.Xauthority")
with subtest("Check RetroArch started"):
machine.wait_until_succeeds("pgrep retroarch")
machine.wait_for_window("^RetroArch ")
with subtest("Check configuration created"):
machine.wait_for_file("${user.home}/.config/retroarch/retroarch.cfg")
with subtest("Wait to get a screenshot"):
machine.execute(
"${xdo} key Alt+F1 sleep 10"
)
machine.screenshot("screen")
'';
})