Nix expr: build w/o `.git`, fix debugPInvokes, add comment re: Cachix

This commit is contained in:
YoshiRulz 2021-12-09 03:02:46 +10:00
parent c8ef579b8f
commit 3d5578df1a
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 37 additions and 21 deletions

View File

@ -58,7 +58,7 @@ in rec {
fi
export LD_LIBRARY_PATH=$BIZHAWK_HOME/dll:$BIZHAWK_GLHACKDIR:${lib.makeLibraryPath [ openal ]}
${commentUnless debugPInvokes}MONO_LOG_LEVEL=debug MONO_LOG_MASK=dll
${commentUnless debugPInvokes}export MONO_LOG_LEVEL=debug MONO_LOG_MASK=dll
if [ "$1" = "--mono-no-redirect" ]; then
shift
printf "(received --mono-no-redirect, stdout was not captured)\n" >EmuHawkMono_laststdout.txt

View File

@ -1,4 +1,5 @@
# THIS IS A WORK IN PROGRESS!
# To save you having to build Mono locally, install the Cachix client (`nix-env -iA nixpkgs.cachix`) and run `cachix use mono-for-bizhawk` (both commands only need to run once ever). See https://docs.cachix.org for more info.
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/21.11.tar.gz") {}
# infrastructure
@ -9,26 +10,33 @@
, makeWrapper ? pkgs.makeWrapper
# source
, useCWDAsSource ? false
, hawkVersion ? if useCWDAsSource then "2.7.1-local" else "2.7" # used to distinguish parallel installs' config and other data
, hawkSource ? if useCWDAsSource
then builtins.path {
path = ./.;
name = "BizHawk-${hawkVersion}";
filter = let
denyList = [ ".idea" "ExternalCoreProjects" "ExternalProjects" "ExternalToolProjects" "libHawk" "libmupen64plus" "LibretroBridge" "LuaInterface" "lynx" "psx" "quicknes" "submodules" "waterbox" "wonderswan" ];
in path: type: type == "regular" || (type == "directory" && !builtins.elem (baseNameOf path) denyList);
, hawkSourceInfo ? if useCWDAsSource
then rec {
version = "2.7.1-local"; # distinguishes parallel installs' config and other data
shorthash = "000000000"; # this and the branch name are written into movies and savestates, written to config to detect in-place upgrades (N/A to Nix), and of course also shown in the About dialog
branch = "master"; # must be regex-escaped (interpolated as `sed "s/.../${branch}/"`)
drv = builtins.path {
path = ./.;
name = "BizHawk-${version}";
filter = let # this is just for speed, not any r13y concern
denyList = [ ".idea" "ExternalCoreProjects" "ExternalProjects" "ExternalToolProjects" "libHawk" "libmupen64plus" "LibretroBridge" "LuaInterface" "lynx" "psx" "quicknes" "submodules" "waterbox" "wonderswan" ];
in path: type: type == "regular" || (type == "directory" && !builtins.elem (baseNameOf path) denyList);
};
}
else fetchFromGitHub {
owner = "TASEmulators";
repo = "BizHawk";
rev = "dbaf2595625f79093eeec37d2d4a7a9a4d37f370";
hash = "sha256-AQhnBy8lSiuFqA6I7lk6M1u3osAJEoEMELGDgGC/aII="; # changes randomly? maybe when submodules are changed? --yoshi
leaveDotGit = true;
else {
version = "2.7";
shorthash = "dbaf25956";
branch = "master";
drv = fetchFromGitHub {
owner = "TASEmulators";
repo = "BizHawk";
rev = "dbaf2595625f79093eeec37d2d4a7a9a4d37f370";
hash = "sha256-KXe69svPIIFaXgT9t+02pwdQ6WWqdqgUdtaE2S4/YxA=";
};
}
# makedeps
, dotnet-sdk_5 ? pkgs.dotnetCorePackages.sdk_5_0
, dotnet-sdk_6 ? pkgs.dotnetCorePackages.sdk_6_0
, git ? pkgs.git
, p7zip ? pkgs.p7zip
# rundeps for NixOS hosts
#, gtk2-x11 ? pkgs.gtk2-x11
@ -55,14 +63,21 @@ let
else pkgs.callPackage Dist/mono-6.12.0.151.nix {}; # not actually reproducible :( https://github.com/NixOS/nixpkgs/issues/143110#issuecomment-984251253
bizhawk = buildDotnetModule rec {
pname = "BizHawk";
version = hawkVersion;
src = hawkSource;
version = hawkSourceInfo.version;
src = hawkSourceInfo.drv;
dotnet-sdk = if useCWDAsSource then dotnet-sdk_6 else dotnet-sdk_5;
nativeBuildInputs = [ git p7zip ];
nativeBuildInputs = [ p7zip ];
buildInputs = [ mesa monoFinal openal uname ];# ++ lib.optionals (forNixOS) [ gtk2-x11 ];
projectFile = "BizHawk.sln";
nugetDeps = if useCWDAsSource then Dist/deps.nix else Dist/deps-old.nix;
extraDotnetBuildFlags = "-maxcpucount:$NIX_BUILD_CORES -p:BuildInParallel=true --no-restore";
postPatch = ''
# confused? '$(...)' is literal here
# these scripts invoke Git in subshells and we want to run them now, at compile time, without Git
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
'';
buildPhase = ''
${commentUnless useCWDAsSource}cd src/BizHawk.Version
${commentUnless useCWDAsSource}dotnet build ${extraDotnetBuildFlags}
@ -89,14 +104,15 @@ let
};
wrapperScripts = import Dist/wrapper-scripts.nix {
inherit (pkgs) lib writeShellScriptBin writeText;
inherit commentUnless versionAtLeast mesa openal debugPInvokes hawkVersion initConfig;
inherit commentUnless versionAtLeast mesa openal debugPInvokes initConfig;
hawkVersion = hawkSourceInfo.version;
mono = monoFinal;
};
in {
bizhawkAssemblies = bizhawk;
emuhawk = stdenv.mkDerivation rec {
pname = "emuhawk-monort";
version = hawkVersion;
version = hawkSourceInfo.version;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ bizhawk ];
# there must be a helper for this somewhere...