add retroarch module

This commit is contained in:
sinavir 2024-01-15 15:14:30 +01:00
parent c6c29599cc
commit 01a1ba39bf
6 changed files with 3323 additions and 3 deletions

View file

@ -1,8 +1,9 @@
({ modulesPath, config, lib, pkgs, ... }: { ({ modulesPath, config, lib, pkgs, ... }: {
imports = [ imports = [
./modules/es-config.nix ./modules
"${modulesPath}/profiles/qemu-guest.nix" "${modulesPath}/profiles/qemu-guest.nix"
./games.nix ./games.nix
./retroarch
]; ];
system.stateVersion = "23.11"; system.stateVersion = "23.11";

View file

@ -1,9 +1,13 @@
{pkgs, ...}: { { config, pkgs, ...}:
let
inherit (config.retronix.retroarch) mapRetroarchConfig;
in
{
retronix = { retronix = {
systems = { systems = {
"Arcade" = { "Arcade" = {
extension = ".sh"; extension = ".sh";
games = with pkgs.roms; [ games = with pkgs.roms; mapRetroarchConfig {} [
atetris atetris
dkong dkong
mario mario

6
modules/default.nix Normal file
View file

@ -0,0 +1,6 @@
{
imports = [
./es-config.nix
./retroarch.nix
];
}

32
modules/retroarch.nix Normal file
View file

@ -0,0 +1,32 @@
{ lib, pkgs, config, ...}:{
options = {
retronix.retroarch = {
settings = lib.mkOption {
description = "Global settings for retroarch instances overriden by add RetroarchConfig";
type = lib.types.attrsOf lib.types.str;
};
addRetroarchConfig = lib.mkOption {
description = "Function to append retroarch config to a rom";
type = lib.types.anything;
};
mapRetroarchConfig = lib.mkOption {
description = "Function to append retroarch config to a list of rom";
type = lib.types.anything;
};
};
};
config = {
retronix.retroarch = {
addRetroarchConfig =
{ additionalConfig ? {}, useBaseConfig ? true }: rom:
rom.override {
settings = if useBaseConfig
then config.retronix.retroarch.settings // additionalConfig
else additionalConfig;
};
mapRetroarchConfig =
args: builtins.map (config.retronix.retroarch.addRetroarchConfig args);
};
};
}

14
retroarch/default.nix Normal file
View file

@ -0,0 +1,14 @@
{ config, pkgs, lib, ... }:
{
retronix.retroarch.settings = (import ./settings.nix) // {
assets_directory = "${pkgs.retroarch-assets}/share/retroarch/assets";
joypad_autoconfig_dir = "${pkgs.retroarch-joypad-autoconfig}/share/libretro/autoconfig";
libretro_info_path = "${pkgs.libretro-core-info}/share/retroarch/cores";
video_shader_dir = builtins.toString (pkgs.fetchFromGitHub {
owner = "RetroPie";
repo = "common-shaders";
rev = "7ab98be403804fe45c71e616c75716eff471bf9c";
hash = "sha256-OHxl1y/UTnkY/UAUaghwWKRktuGWPIOTjd906Ckgv/g=";
});
};
}

3263
retroarch/settings.nix Normal file

File diff suppressed because it is too large Load diff