From 665ca18fbcb0712476f31cc32877d24eef47792e Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Tue, 8 Mar 2022 10:17:18 +1000 Subject: [PATCH] Nix expr: refactor, add pinned 2.8 --- default.nix | 109 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/default.nix b/default.nix index f388b2cba9..9c52a8e78c 100644 --- a/default.nix +++ b/default.nix @@ -9,35 +9,22 @@ #, makeDesktopItem ? pkgs.makeDesktopItem , makeWrapper ? pkgs.makeWrapper # source -, useCWDAsSource ? false -, 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 = [ ".git" ".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 { - version = "2.7"; - shorthash = "dbaf25956"; - branch = "master"; - drv = fetchFromGitHub { - owner = "TASEmulators"; - repo = "BizHawk"; - rev = "dbaf2595625f79093eeec37d2d4a7a9a4d37f370"; - hash = "sha256-KXe69svPIIFaXgT9t+02pwdQ6WWqdqgUdtaE2S4/YxA="; - }; - } +, useCWDAsSource ? false # deprecated +, hawkSourceInfoDev ? rec { + version = "2.8.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 = [ ".git" ".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); + }; +} # makedeps , dotnet-sdk_5 ? pkgs.dotnetCorePackages.sdk_5_0 , dotnet-sdk_6 ? pkgs.dotnetCorePackages.sdk_6_0 -, p7zip ? pkgs.p7zip # rundeps for NixOS hosts #, gtk2-x11 ? pkgs.gtk2-x11 # rundeps for all Linux hosts @@ -61,16 +48,15 @@ let else if versionAtLeast "6.12.0.151" pkgs.mono.version then pkgs.mono 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 { + buildAssembliesFor = hawkSourceInfo: buildDotnetModule rec { 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 ]; + dotnet-sdk = if hawkSourceInfo ? dotnet-sdk then hawkSourceInfo.dotnet-sdk else dotnet-sdk_6; 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; + nugetDeps = if hawkSourceInfo ? nugetDeps then hawkSourceInfo.nugetDeps else Dist/deps.nix; extraDotnetBuildFlags = "-maxcpucount:$NIX_BUILD_CORES -p:BuildInParallel=true --no-restore"; postPatch = '' # confused? '$(...)' is literal here @@ -84,9 +70,9 @@ let sed -i '/mkdir "packaged_output\/Firmware/d' Dist/Package.sh # and we don't need this ''; buildPhase = '' - ${commentUnless useCWDAsSource}cd src/BizHawk.Version - ${commentUnless useCWDAsSource}dotnet build ${extraDotnetBuildFlags} - ${commentUnless useCWDAsSource}cd ../.. + cd src/BizHawk.Version + dotnet build ${extraDotnetBuildFlags} + cd ../.. Dist/Build${buildConfig}.sh ${extraDotnetBuildFlags} printf "NixHawk" >output/dll/custombuild.txt Dist/Package.sh linux-x64 @@ -111,18 +97,19 @@ let ''; dontPatchELF = true; }; - wrapperScripts = import Dist/wrapper-scripts.nix { + wrapperScriptsFor = { hawkSourceInfo, bizhawkAssemblies }: import Dist/wrapper-scripts.nix { inherit (pkgs) lib writeShellScriptBin writeText; - inherit commentUnless versionAtLeast bizhawk mesa openal debugPInvokes initConfig; + inherit commentUnless versionAtLeast mesa openal debugPInvokes initConfig; + bizhawk = bizhawkAssemblies; hawkVersion = hawkSourceInfo.version; mono = monoFinal; }; - mkWrapperWrapper = { pname, innerWrapper, desktopName }: stdenv.mkDerivation rec { + mkWrapperWrapper = { hawkSourceInfo, bizhawkAssemblies, pname, innerWrapper, desktopName }: stdenv.mkDerivation rec { inherit pname; version = hawkSourceInfo.version; exeName = "${pname}-${version}"; nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ bizhawk ]; + buildInputs = [ bizhawkAssemblies ]; # there must be a helper for this somewhere... dontUnpack = true; dontPatch = true; @@ -131,7 +118,7 @@ let installPhase = '' mkdir -p $out/bin makeWrapper ${innerWrapper} $out/bin/${exeName} \ - --set BIZHAWK_HOME ${bizhawk} + --set BIZHAWK_HOME ${bizhawkAssemblies} ''; dontFixup = true; # desktopItems = [ (makeDesktopItem { @@ -140,20 +127,56 @@ let # inherit desktopName; # actually Name # }) ]; }; -in { - bizhawkAssemblies = bizhawk; # assemblies and dependencies, and some other immutable things like the gamedb, are in the `bin` output; the rest of the "assets" (bundled scripts, palettes, etc.) are in the `out` output - discohawk = mkWrapperWrapper { + buildDiscoHawkWrapperFor = { hawkSourceInfo, bizhawkAssemblies ? buildAssembliesFor hawkSourceInfo }: let + wrapperScripts = wrapperScriptsFor { inherit hawkSourceInfo bizhawkAssemblies; }; + in mkWrapperWrapper { + inherit hawkSourceInfo bizhawkAssemblies; pname = "discohawk-monort"; innerWrapper = "${wrapperScripts.discoWrapper}/bin/discohawk-wrapper"; desktopName = "DiscoHawk (Mono Runtime)"; }; - emuhawk = mkWrapperWrapper { + buildEmuHawkWrapperFor = { hawkSourceInfo, bizhawkAssemblies ? buildAssembliesFor hawkSourceInfo }: let + wrapperScripts = wrapperScriptsFor { inherit hawkSourceInfo bizhawkAssemblies; }; + in mkWrapperWrapper { + inherit hawkSourceInfo bizhawkAssemblies; pname = "emuhawk-monort"; innerWrapper = if forNixOS then "${wrapperScripts.wrapperScript}/bin/emuhawk-wrapper" else "${wrapperScripts.wrapperScriptNonNixOS}/bin/emuhawk-wrapper-non-nixos"; desktopName = "EmuHawk (Mono Runtime)"; }; - emuhawkWrapperScriptNonNixOS = wrapperScripts.wrapperScriptNonNixOS; +in rec { + bizhawkAssemblies = buildAssembliesFor hawkSourceInfoDev; # assemblies and dependencies, and some other immutable things like the gamedb, are in the `bin` output; the rest of the "assets" (bundled scripts, palettes, etc.) are in the `out` output + discohawk = buildDiscoHawkWrapperFor { inherit bizhawkAssemblies; hawkSourceInfo = hawkSourceInfoDev; }; + emuhawk-2_7 = buildEmuHawkWrapperFor { + hawkSourceInfo = { + version = "2.7"; + shorthash = "dbaf25956"; + branch = "master"; + drv = fetchFromGitHub { + owner = "TASEmulators"; + repo = "BizHawk"; + rev = "dbaf2595625f79093eeec37d2d4a7a9a4d37f370"; + hash = "sha256-KXe69svPIIFaXgT9t+02pwdQ6WWqdqgUdtaE2S4/YxA="; + }; + dotnet-sdk = dotnet-sdk_5; + nugetDeps = Dist/deps-old.nix; + }; + }; + emuhawk-2_8 = buildEmuHawkWrapperFor { + hawkSourceInfo = { + version = "2.8"; + shorthash = "e731e0f32"; + branch = "master"; + drv = fetchFromGitHub { + owner = "TASEmulators"; + repo = "BizHawk"; + rev = "e731e0f32903cd40b83ed75bba3b1e3753105ce2"; + hash = "sha256-kP6zvTbhctqGCmjDOtQgBGII1T0xIyN5keq7d/lfWVM="; + }; + }; + }; + emuhawk = buildEmuHawkWrapperFor { inherit bizhawkAssemblies; hawkSourceInfo = hawkSourceInfoDev; }; + emuhawkWrapperScriptNonNixOS = (wrapperScriptsFor { inherit bizhawkAssemblies; hawkSourceInfo = hawkSourceInfoDev; }).wrapperScriptNonNixOS; mono = monoFinal; }