54 lines
1 KiB
Nix
54 lines
1 KiB
Nix
{ runCommand, runtimeShell, stdenv, shellcheck-minimal, lib, lndir }:
|
|
{ name
|
|
, src
|
|
, runtimeInputs ? [ ]
|
|
, command
|
|
, meta ? {}
|
|
}:
|
|
runCommand name {
|
|
inherit meta src;
|
|
allowSubstitutes = true;
|
|
preferLocalBuild = false;
|
|
|
|
launchPath = "launch.sh";
|
|
|
|
script = ''
|
|
#!${runtimeShell}
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
'' + lib.optionalString (runtimeInputs != [ ]) ''
|
|
|
|
export PATH="${lib.makeBinPath runtimeInputs}:$PATH"
|
|
'' + ''
|
|
|
|
${command}
|
|
'';
|
|
|
|
passAsFile = [ "script" ];
|
|
|
|
checkPhase = ''
|
|
runHook preCheck
|
|
${stdenv.shellDryRun} "$target"
|
|
${lib.getExe shellcheck-minimal} "$target"
|
|
runHook postCheck
|
|
'';
|
|
|
|
} ''
|
|
target=$out/bin/${lib.escapeShellArg name}
|
|
rom_dir=$out/usr/share
|
|
|
|
mkdir -p "$(dirname "$target")"
|
|
mkdir -p "$rom_dir"
|
|
|
|
# symlink rom_dir
|
|
${lndir}/bin/lndir $src $rom_dir
|
|
|
|
mv "$scriptPath" "$target"
|
|
chmod +x "$target"
|
|
|
|
# symlink the executable to help emulation station calls
|
|
ln -s $target $out/$launchPath
|
|
|
|
eval "$checkPhase"
|
|
''
|