How to create a launcher for x16emu and x16rom?

Hello, people!

I have packaged Commander-X16 rom and emulator. As always, the emulator needs the rom in order to work properly, like a firmware-hardware relationship.

The official README says this about a typical operation of this:


You can start x16emu / x16emu.exe either by double-clicking it, or from the command line. The latter allows you to specify additional arguments.

  • When starting x16emu without arguments, it will pick up the system ROM ( rom.bin ) from the executable’s directory.
  • The system ROM filename/path can be overridden with the -rom command line argument.

Certainly the first bullet is not possible, because the way Nixpkgs works. Different packages are sent to different locations, therefore x16emu can’t find rom.bin.

This way, I want to create a shell script that emulates (ba dum tss) the above behaviour:

  1. If the -rom commandline argument is not passed, it injects -rom <location of official rom in nix store>; else, do nothing
  2. pass the commandline generated in the previous step to the x16emu program itself

This way we can use this script, call it x16run, as the ‘official nixpkgs launcher’.

My question is: how can I do it?

nice derivation!.

I’ve been studying how nix/OS handles such situations, looking thru nixpkgs, if a package has plugins/mods or some kind of shared data, it seems use a combination of wrappers and symlinkjoin.

This might be exactly what your looking for, to basically joining the two outputs together.

here is an example, there are simpler ones in nixpkgs, ripgrep is your friend.

maybe someone can give a more concrete or simple example of this.

Many things in nixpkgs use a convenient withPackages construct… like python3.withPackages , but this is probably a bit overkill for what your trying to do at this level. It’s next on my every growing nix research list.

Maybe for ‘rom files’ , they shouldn’t live in nix land at all, as each package you add increases the nix lang’s evaluation time. Perhaps data files should live in the users home area, it’s not shareable however, but you can then just use a normal construct of "mysuperemular /home/fred/roms/myrom.rom ???

I’m not sure what the ‘right’ approach is , but it must happen, especially with things than need data, like extra fonts etc etc.

Maybe sharable data is an excellent use case for nix flakes ??? however more research is needed from me

This is an official rom/firmware file, generated by compiling the source code. If it has a source code, then it can be put in Nix Store.

Also, the upstream developers strongly suggest both softwares, the emulator and the firmware/rom file, are meant to be used together. Although a casual hacker can change this romfile by a custom version, the recommended setup is to use this rom as a default.

It doesn’t and shouldn’t hinder the user to provide a third-party rom.