From 37916df9d0e23a4408e823ad45bb96b2f0424ca4 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 16 Jun 2021 15:25:28 -0300 Subject: [PATCH] commanderx16: create x16-run script In a typical FHS-compliant system, the rom and the emulator share the same directory tree, and x16emu explores it. But Nix/Nixpkgs breaks this assumption. Therefore, I made a useful script tailored to a regular user of Nixpkgs invoke it in a more straightforward way. With this, the end user does not need to explicitly set the default rom path. --- pkgs/misc/emulators/commander-x16/run.nix | 39 +++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 +++ 2 files changed, 43 insertions(+) create mode 100644 pkgs/misc/emulators/commander-x16/run.nix diff --git a/pkgs/misc/emulators/commander-x16/run.nix b/pkgs/misc/emulators/commander-x16/run.nix new file mode 100644 index 000000000000..cf14252b487c --- /dev/null +++ b/pkgs/misc/emulators/commander-x16/run.nix @@ -0,0 +1,39 @@ +{ lib +, stdenv +, runtimeShell +, symlinkJoin +, writeTextFile +}: + +{ emulator, rom }: + +assert emulator.version == rom.version; + +let + runScript = writeTextFile { + name = "run-x16"; + text = '' + #!${runtimeShell} + + defaultRom="${rom}/share/x16-rom/rom.bin" + + exec "${emulator}/bin/x16emu" -rom $defaultRom "$@" + ''; + executable = true; + destination = "/bin/run-x16"; + }; +in +symlinkJoin { + name = "run-x16-${emulator.version}"; + + paths = [ + emulator + rom + runScript + ]; +} +# TODO [ AndersonTorres ]: + +# 1. Parse the command line in order to allow the user to set an optional +# rom-file +# 2. generate runScript based on symlinkJoin (maybe a postBuild?) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2cb0404e139e..07ec28f70e85 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -31617,6 +31617,10 @@ in x16-emulator = callPackage ../misc/emulators/commander-x16/emulator.nix { }; x16-rom = callPackage ../misc/emulators/commander-x16/rom.nix { }; + x16-run = (callPackage ../misc/emulators/commander-x16/run.nix { }) { + emulator = x16-emulator; + rom = x16-rom; + }; bullet = callPackage ../development/libraries/bullet { inherit (darwin.apple_sdk.frameworks) Cocoa OpenGL;