RetroArch: Difference between revisions

From NixOS Wiki
imported>JasonWoof
Show how to install/run RetroArch with cores
 
Peeley (talk | contribs)
Provide example for the retroarch.withCores interface
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== RetroArch ==
== Installation ==
[https://www.retroarch.com/ RetroArch] is available in nixpkgs via a few different packages,


You can install retroarch with some cores (actual emulators) by putting something like this in your /etc/nixos/configuration.nix
* <code>retroarch-full</code>, contains all libretro cores
* <code>retroarch-free</code>, contains only cores available under a free-software license
* <code>retroarch.withCores</code>, a helper function for generating a retroarch package with a custom list of cores.


<syntaxhighlight lang="nix">
=== Installing only certain cores ===
In NixOS 24.11, you override the retroarch derivation to pass a list of custom cores like below.<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [
environment.systemPackages = with pkgs; [
    (retroarch.override { cores = with libretro; [ genesis-plus-gx snes9x beetle-psx-hw ]; })
  (retroarch.override {
    libretro.genesis-plus-gx
    cores = with libretro; [
    libretro.snes9x
      genesis-plus-gx
    libretro.beetle-psx-hw
      snes9x
      beetle-psx-hw
    ];
  })
];
];
</syntaxhighlight>
</syntaxhighlight>


FIXME: where is the list of cores that libretro exports?
After NixOS 24.11, the RetroArch derivation was refactored, and the interface is now <code>retroarch.withCores</code>:<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [
  (retroarch.withCores (cores: with cores; [
    genesis-plus-gx
    snes9x
    beetle-psx-hw
  ]))
];
</syntaxhighlight>
 
== Gotchas ==


In the meantime, maybe these strings work: https://gist.github.com/GrahamcOfBorg/fa41301565a858134941b91179822b7d
=== Graphics ===
Not all the graphics settings are in the same place. You'll want to look under the top-level Settings (in the left column under Main Menu) and also under <code>Main Menu -> Quick Menu -> Options</code>


Once you update your system you can run <code>retroarch</code> to access the main gui, or eg <code>retroarch-mednafen-psx-hw my-game-file.cue</code> to run a game directly.
=== Mapping ===
The following way to remap a controller or map a new controller is convoluted, but works and allows you to upstream your changes.


# Fork the [https://github.com/libretro/retroarch-joypad-autoconfig retroarch-joypad-autoconfig] project and clone it in a folder of your choosing.
# With Retroarch open, go to Settings > Directory and change Controller Profiles to point to the same folder. Note: Do not attempt to modify the directory in <code>retroarch.cfg</code> directly because it will be overwritten on startup.
# Now, saving the mapping will work but this will be ignored on next startup of Retroarch.
# After you are happy with the mapping, commit the changes in the folder where you cloned the retroarch-joypad-autoconfig project and push them to your fork.
# To use what you just pushed in your configuration right away, add the following overlay to your nix config by replacing the various fields with those corresponding to your fork:<syntaxhighlight lang="nix">
(final: prev: {
  retroarch-joypad-autoconfig = prev.retroarch-joypad-autoconfig.overrideAttrs {
    src = prev.fetchFromGitHub {
      owner = "ibizaman";
      repo = "retroarch-joypad-autoconfig";
      rev = "420a8fa4dc7b12f7c176fa0e704e9f987f6ceabd";
      hash = "sha256-yIvW9UTgc+/hhwx+93FgzrDBEBD35xFdBiVdJCKUYBc=";
    };
  };
})
</syntaxhighlight>
# After switching over to the new configuration and restarting Retroarch, you will see the mappings got updated.
# Now you can create a pull request from your fork to the retroarch-joypad-autoconfig project to upstream your changes.


== Gotchas ==
== Bugs ==
 
=== Input Reset ===


Not all the graphics settings are in the same place. You'll want to look under the top-level Settings (in the left column under Main Menu) and also under Main Menu -> Quick Menu -> Options
beetle-psx-hw input (by keyboard anyway) only works if you go to <code>Settings -> Input -> Port 1 Controls -> Device Type</code> and set it to PlayStation Controller '''every time you run the emulator'''.


=== Missing Icons ===


== Bugs ==
No icons show in the GUI, including the mouse cursor. You need to go to <code>Online Updater > Update Assets</code> to download the icons. You can navigate the GUI with only the keyboard. Press enter to open sections/pages, backspace to go back out, arrow keys to choose between options (left/right change some values).


beetle-psx-hw input (by keyboard anyway) only works if you go to Settings -> Input -> Port 1 Controls -> Device Type and set it to PlayStation Controller '''every time you run the emulator'''.
== Error Messages ==


No icons show in the gui, including the mouse cursor. you can use the gui with only the keyboard though. Press enter to open  sections/pages, backspace to go back out. arrow keys to choose between options (left/right change some values).
=== Error save controller profile ===
This is because the location of the controller profile is in the nix store, making it read-only. To actually remap a controller, see the [[RetroArch#Mapping|Mapping]] section.
[[Category:Applications]]
[[Category:Gaming]]

Latest revision as of 21:38, 8 February 2025

Installation

RetroArch is available in nixpkgs via a few different packages,

  • retroarch-full, contains all libretro cores
  • retroarch-free, contains only cores available under a free-software license
  • retroarch.withCores, a helper function for generating a retroarch package with a custom list of cores.

Installing only certain cores

In NixOS 24.11, you override the retroarch derivation to pass a list of custom cores like below.

environment.systemPackages = with pkgs; [
  (retroarch.override {
    cores = with libretro; [
      genesis-plus-gx
      snes9x
      beetle-psx-hw
    ];
  })
];

After NixOS 24.11, the RetroArch derivation was refactored, and the interface is now retroarch.withCores:

environment.systemPackages = with pkgs; [
  (retroarch.withCores (cores: with cores; [
    genesis-plus-gx
    snes9x
    beetle-psx-hw
  ]))
];

Gotchas

Graphics

Not all the graphics settings are in the same place. You'll want to look under the top-level Settings (in the left column under Main Menu) and also under Main Menu -> Quick Menu -> Options

Mapping

The following way to remap a controller or map a new controller is convoluted, but works and allows you to upstream your changes.

  1. Fork the retroarch-joypad-autoconfig project and clone it in a folder of your choosing.
  2. With Retroarch open, go to Settings > Directory and change Controller Profiles to point to the same folder. Note: Do not attempt to modify the directory in retroarch.cfg directly because it will be overwritten on startup.
  3. Now, saving the mapping will work but this will be ignored on next startup of Retroarch.
  4. After you are happy with the mapping, commit the changes in the folder where you cloned the retroarch-joypad-autoconfig project and push them to your fork.
  5. To use what you just pushed in your configuration right away, add the following overlay to your nix config by replacing the various fields with those corresponding to your fork:
    (final: prev: {
      retroarch-joypad-autoconfig = prev.retroarch-joypad-autoconfig.overrideAttrs {
        src = prev.fetchFromGitHub {
          owner = "ibizaman";
          repo = "retroarch-joypad-autoconfig";
          rev = "420a8fa4dc7b12f7c176fa0e704e9f987f6ceabd";
          hash = "sha256-yIvW9UTgc+/hhwx+93FgzrDBEBD35xFdBiVdJCKUYBc=";
        };
      };
    })
    
  6. After switching over to the new configuration and restarting Retroarch, you will see the mappings got updated.
  7. Now you can create a pull request from your fork to the retroarch-joypad-autoconfig project to upstream your changes.

Bugs

Input Reset

beetle-psx-hw input (by keyboard anyway) only works if you go to Settings -> Input -> Port 1 Controls -> Device Type and set it to PlayStation Controller every time you run the emulator.

Missing Icons

No icons show in the GUI, including the mouse cursor. You need to go to Online Updater > Update Assets to download the icons. You can navigate the GUI with only the keyboard. Press enter to open sections/pages, backspace to go back out, arrow keys to choose between options (left/right change some values).

Error Messages

Error save controller profile

This is because the location of the controller profile is in the nix store, making it read-only. To actually remap a controller, see the Mapping section.