mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-05 16:41:04 +01:00
retroarch: add module
add a module for configuring retroarch through home-manager
This commit is contained in:
parent
a31a6b2d30
commit
be4a9233dd
6 changed files with 202 additions and 0 deletions
12
modules/misc/news/2025/11/2025-11-08_20-50-07.nix
Normal file
12
modules/misc/news/2025/11/2025-11-08_20-50-07.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
time = "2025-11-08T20:50:07+00:00";
|
||||||
|
condition = pkgs.stdenv.hostPlatform.isLinux;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'programs.retroarch'.
|
||||||
|
|
||||||
|
RetroArch is a frontend for emulators, game engines, and media players.
|
||||||
|
Among other things, it enables you to run classic games on a wide
|
||||||
|
range of computers and consoles through its slick graphical interface.
|
||||||
|
'';
|
||||||
|
}
|
||||||
91
modules/programs/retroarch.nix
Normal file
91
modules/programs/retroarch.nix
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.programs.retroarch;
|
||||||
|
|
||||||
|
enabledCores = lib.filterAttrs (_: core: core.enable) cfg.cores;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = [
|
||||||
|
lib.hm.maintainers.jtrrll
|
||||||
|
];
|
||||||
|
|
||||||
|
options.programs.retroarch = {
|
||||||
|
enable = lib.mkEnableOption "RetroArch";
|
||||||
|
|
||||||
|
package = lib.mkPackageOption pkgs "retroarch" {
|
||||||
|
default = "retroarch-bare";
|
||||||
|
};
|
||||||
|
|
||||||
|
finalPackage = lib.mkOption {
|
||||||
|
type = lib.types.package;
|
||||||
|
readOnly = true;
|
||||||
|
description = ''
|
||||||
|
Resulting RetroArch package.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
cores = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (
|
||||||
|
lib.types.submodule (
|
||||||
|
{ name, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
enable = lib.mkEnableOption "RetroArch core";
|
||||||
|
package = lib.mkPackageOption pkgs [ "libretro" name ] { };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
default = { };
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
{
|
||||||
|
mgba.enable = true; # Uses pkgs.libretro.mgba
|
||||||
|
snes9x = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.libretro.snes9x2010;
|
||||||
|
};
|
||||||
|
custom-core = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.callPackage ./custom-core.nix { };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
RetroArch cores to enable. You can provide custom core packages.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.str;
|
||||||
|
default = { };
|
||||||
|
example = {
|
||||||
|
input_max_users = "4";
|
||||||
|
menu_scale_factor = "0.950000";
|
||||||
|
netplay_nickname = "username";
|
||||||
|
video_driver = "vulkan";
|
||||||
|
video_fullscreen = "true";
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
RetroArch configuration settings.
|
||||||
|
|
||||||
|
See <https://github.com/libretro/RetroArch/blob/master/retroarch.cfg>
|
||||||
|
for available configuration options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
programs.retroarch.finalPackage = (
|
||||||
|
cfg.package.wrapper {
|
||||||
|
inherit (cfg) settings;
|
||||||
|
cores = lib.mapAttrsToList (_: core: core.package) enabledCores;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
home.packages = [ cfg.finalPackage ];
|
||||||
|
};
|
||||||
|
}
|
||||||
34
tests/modules/programs/retroarch/cores.nix
Normal file
34
tests/modules/programs/retroarch/cores.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
{
|
||||||
|
imports = [ ./stubs.nix ];
|
||||||
|
|
||||||
|
programs.retroarch = {
|
||||||
|
enable = true;
|
||||||
|
cores = {
|
||||||
|
mgba.enable = true;
|
||||||
|
snes9x = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.libretro.snes9x2010;
|
||||||
|
};
|
||||||
|
custom = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage {
|
||||||
|
buildScript = ''
|
||||||
|
mkdir -p $out/lib/retroarch/cores
|
||||||
|
touch $out/lib/retroarch/cores/custom_libretro.so
|
||||||
|
'';
|
||||||
|
extraAttrs.libretroCore = "/lib/retroarch/cores";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-path/bin/retroarch
|
||||||
|
assertFileRegex home-path/bin/retroarch 'L.*lib/retroarch/cores'
|
||||||
|
|
||||||
|
assertFileExists home-path/lib/retroarch/cores/mgba_libretro.so
|
||||||
|
assertFileExists home-path/lib/retroarch/cores/snes9x2010_libretro.so
|
||||||
|
assertFileExists home-path/lib/retroarch/cores/custom_libretro.so
|
||||||
|
'';
|
||||||
|
}
|
||||||
5
tests/modules/programs/retroarch/default.nix
Normal file
5
tests/modules/programs/retroarch/default.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||||
|
retroarch-cores = ./cores.nix;
|
||||||
|
retroarch-settings = ./settings.nix;
|
||||||
|
}
|
||||||
28
tests/modules/programs/retroarch/settings.nix
Normal file
28
tests/modules/programs/retroarch/settings.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
imports = [ ./stubs.nix ];
|
||||||
|
|
||||||
|
programs.retroarch = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
input_max_users = "4";
|
||||||
|
menu_scale_factor = "0.950000";
|
||||||
|
netplay_nickname = "username";
|
||||||
|
video_driver = "vulkan";
|
||||||
|
video_fullscreen = "true";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-path/bin/retroarch
|
||||||
|
assertFileRegex home-path/bin/retroarch 'appendconfig.*declarative-retroarch\.cfg'
|
||||||
|
|
||||||
|
configFile=$(grep -aoP '/nix/store/[a-z0-9]+-declarative-retroarch\.cfg' $TESTED/home-path/bin/retroarch | head -1)
|
||||||
|
assertFileExists "$configFile"
|
||||||
|
assertFileContains "$configFile" 'input_max_users = "4"'
|
||||||
|
assertFileContains "$configFile" 'menu_scale_factor = "0.950000"'
|
||||||
|
assertFileContains "$configFile" 'netplay_nickname = "username"'
|
||||||
|
assertFileContains "$configFile" 'video_driver = "vulkan"'
|
||||||
|
assertFileContains "$configFile" 'video_fullscreen = "true"'
|
||||||
|
'';
|
||||||
|
}
|
||||||
32
tests/modules/programs/retroarch/stubs.nix
Normal file
32
tests/modules/programs/retroarch/stubs.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
realPkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
mkLibretroCore =
|
||||||
|
name:
|
||||||
|
config.lib.test.mkStubPackage {
|
||||||
|
buildScript = ''
|
||||||
|
mkdir -p $out/lib/retroarch/cores
|
||||||
|
touch $out/lib/retroarch/cores/${name}_libretro.so
|
||||||
|
'';
|
||||||
|
extraAttrs.libretroCore = "/lib/retroarch/cores";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
test.stubs = {
|
||||||
|
libretro = {
|
||||||
|
extraAttrs = {
|
||||||
|
mgba = mkLibretroCore "mgba";
|
||||||
|
snes9x2010 = mkLibretroCore "snes9x2010";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
retroarch-bare = {
|
||||||
|
extraAttrs = {
|
||||||
|
inherit (realPkgs.retroarch-bare) wrapper;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue