Nix expr: copy bundled scripts, shaders, etc. to ~/.local/share

TODOs excepted, this brings the Nix build to feature-parity with "portable"/AUR
builds... if it runs at all (i.e. for the distros in `wrapper-scripts.nix`)
This commit is contained in:
YoshiRulz 2021-12-13 19:33:05 +10:00
parent fdee066fd1
commit 878b22e8c5
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 25 additions and 12 deletions

View File

@ -5,6 +5,7 @@
, writeShellScriptBin
, writeText
# rundeps
, bizhawk
, mesa
, mono
, openal
@ -49,13 +50,16 @@ in rec {
BIZHAWK_DATA_HOME="$HOME/.local/share"
fi
BIZHAWK_DATA_HOME="$BIZHAWK_DATA_HOME/emuhawk-monort-${hawkVersion}"
mkdir -p "$BIZHAWK_DATA_HOME"
cd "$BIZHAWK_DATA_HOME"
if [ ! -e config.json ]; then
cat ${initConfigFile} >config.json # cp kept the perms as 444 -- don't @ me
sed -i "s@%%BIZHAWK_DATA_HOME%%@$BIZHAWK_DATA_HOME@g" config.json
if [ ! -e "$BIZHAWK_DATA_HOME" ]; then
mkdir -p "$BIZHAWK_DATA_HOME"
cd "${bizhawk.out}"
find . -type f -not -wholename "./nix-support/*" -exec install -DvT "{}" "$BIZHAWK_DATA_HOME/{}" \;
fi
if [ ! -e "$BIZHAWK_DATA_HOME/config.json" ]; then
sed "s@%%BIZHAWK_DATA_HOME%%@$BIZHAWK_DATA_HOME@g" "${initConfigFile}" >"$BIZHAWK_DATA_HOME/config.json"
printf "wrote initial config to %s\n" "$BIZHAWK_DATA_HOME/config.json"
fi
cd "$BIZHAWK_DATA_HOME"
export LD_LIBRARY_PATH=$BIZHAWK_HOME/dll:$BIZHAWK_GLHACKDIR:${lib.makeLibraryPath [ openal ]}
${commentUnless debugPInvokes}export MONO_LOG_LEVEL=debug MONO_LOG_MASK=dll

View File

@ -65,6 +65,7 @@ let
pname = "BizHawk";
version = hawkSourceInfo.version;
src = hawkSourceInfo.drv;
outputs = [ "bin" "out" ];
dotnet-sdk = if useCWDAsSource then dotnet-sdk_6 else dotnet-sdk_5;
nativeBuildInputs = [ p7zip ];
buildInputs = [ mesa monoFinal openal uname ];# ++ lib.optionals (forNixOS) [ gtk2-x11 ];
@ -77,6 +78,10 @@ let
sed -i 's/$(git rev-parse --verify HEAD)/${hawkSourceInfo.shorthash}/' Dist/.InvokeCLIOnMainSln.sh
sed -i -e 's/$(git rev-parse --abbrev-ref HEAD)/${hawkSourceInfo.branch}/' -e 's/$(git log -1 --format="%h")/${hawkSourceInfo.shorthash}/' Build/standin.sh
sed -i 's/$(git rev-list HEAD --count)//' Build/standin.sh # const field is unused
# stop MSBuild from copying Assets, we'll do that later
sed -i '/Assets\/\*\*/d' src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
sed -i '/mkdir "packaged_output\/Firmware/d' Dist/Package.sh # and we don't need this
'';
buildPhase = ''
${commentUnless useCWDAsSource}cd src/BizHawk.Version
@ -85,7 +90,6 @@ let
Dist/Build${buildConfig}.sh ${extraDotnetBuildFlags}
printf "Nix" >output/dll/custombuild.txt
Dist/Package.sh linux-x64
rm packaged_output/EmuHawkMono.sh # replaced w/ below script(s)
'';
inherit doCheck;
checkPhase = ''
@ -97,19 +101,24 @@ let
# Dist/Build${buildConfig}.sh -p:MachineRunAnalyzersDuringBuild=true ${extraDotnetBuildFlags}
'';
installPhase = ''
mkdir -p $out
cp -aTv packaged_output $out
cp -avT packaged_output $bin
cp -avt $bin Assets/defctrl.json && rm Assets/defctrl.json
cp -avt $bin/dll Assets/dll/* && rm -r Assets/dll
rm Assets/EmuHawkMono.sh # replaced w/ scripts from wrapperScripts
cp -avt $bin Assets/gamedb && rm -r Assets/gamedb
cp -avt $bin Assets/Shaders && rm -r Assets/Shaders
cp -avT Assets $out
'';
dontPatchELF = true;
};
wrapperScripts = import Dist/wrapper-scripts.nix {
inherit (pkgs) lib writeShellScriptBin writeText;
inherit commentUnless versionAtLeast mesa openal debugPInvokes initConfig;
inherit commentUnless versionAtLeast bizhawk mesa openal debugPInvokes initConfig;
hawkVersion = hawkSourceInfo.version;
mono = monoFinal;
};
in {
bizhawkAssemblies = bizhawk;
bizhawkAssemblies = bizhawk; # assemblies, dependencies, and the gamedb are in `bin` output; bundled scripts, shaders, etc. are in `out` output
emuhawk = stdenv.mkDerivation rec {
pname = "emuhawk-monort";
version = hawkSourceInfo.version;

View File

@ -187,7 +187,7 @@ namespace BizHawk.Client.EmuHawk
{
var gameDbEntry = Emulator.AsGameDBEntryGenerator().GenerateGameDbEntry();
gameDbEntry.Status = picker.PickedStatus;
Database.SaveDatabaseEntry(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb_user.txt"), gameDbEntry);
Database.SaveDatabaseEntry(Path.Combine(PathUtils.ExeDirectoryPath, "gamedb", "gamedb_user.txt"), gameDbEntry); //TODO read-only in Nix builds
MainForm.UpdateDumpInfo(gameDbEntry.Status);
HideShowGameDbButton();
}