Nix expr: refactor, add pinned 2.8

This commit is contained in:
YoshiRulz 2022-03-08 10:17:18 +10:00
parent 6e4a5a96af
commit 665ca18fbc
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 66 additions and 43 deletions

View File

@ -9,35 +9,22 @@
#, makeDesktopItem ? pkgs.makeDesktopItem #, makeDesktopItem ? pkgs.makeDesktopItem
, makeWrapper ? pkgs.makeWrapper , makeWrapper ? pkgs.makeWrapper
# source # source
, useCWDAsSource ? false , useCWDAsSource ? false # deprecated
, hawkSourceInfo ? if useCWDAsSource , hawkSourceInfoDev ? rec {
then rec { version = "2.8.1-local"; # distinguishes parallel installs' config and other data
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
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}/"`)
branch = "master"; # must be regex-escaped (interpolated as `sed "s/.../${branch}/"`) drv = builtins.path {
drv = builtins.path { path = ./.;
path = ./.; name = "BizHawk-${version}";
name = "BizHawk-${version}"; filter = let # this is just for speed, not any r13y concern
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" ];
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);
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=";
};
}
# makedeps # makedeps
, dotnet-sdk_5 ? pkgs.dotnetCorePackages.sdk_5_0 , dotnet-sdk_5 ? pkgs.dotnetCorePackages.sdk_5_0
, dotnet-sdk_6 ? pkgs.dotnetCorePackages.sdk_6_0 , dotnet-sdk_6 ? pkgs.dotnetCorePackages.sdk_6_0
, p7zip ? pkgs.p7zip
# rundeps for NixOS hosts # rundeps for NixOS hosts
#, gtk2-x11 ? pkgs.gtk2-x11 #, gtk2-x11 ? pkgs.gtk2-x11
# rundeps for all Linux hosts # rundeps for all Linux hosts
@ -61,16 +48,15 @@ let
else if versionAtLeast "6.12.0.151" pkgs.mono.version else if versionAtLeast "6.12.0.151" pkgs.mono.version
then pkgs.mono 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 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"; pname = "BizHawk";
version = hawkSourceInfo.version; version = hawkSourceInfo.version;
src = hawkSourceInfo.drv; src = hawkSourceInfo.drv;
outputs = [ "bin" "out" ]; outputs = [ "bin" "out" ];
dotnet-sdk = if useCWDAsSource then dotnet-sdk_6 else dotnet-sdk_5; dotnet-sdk = if hawkSourceInfo ? dotnet-sdk then hawkSourceInfo.dotnet-sdk else dotnet-sdk_6;
nativeBuildInputs = [ p7zip ];
buildInputs = [ mesa monoFinal openal uname ];# ++ lib.optionals (forNixOS) [ gtk2-x11 ]; buildInputs = [ mesa monoFinal openal uname ];# ++ lib.optionals (forNixOS) [ gtk2-x11 ];
projectFile = "BizHawk.sln"; 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"; extraDotnetBuildFlags = "-maxcpucount:$NIX_BUILD_CORES -p:BuildInParallel=true --no-restore";
postPatch = '' postPatch = ''
# confused? '$(...)' is literal here # 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 sed -i '/mkdir "packaged_output\/Firmware/d' Dist/Package.sh # and we don't need this
''; '';
buildPhase = '' buildPhase = ''
${commentUnless useCWDAsSource}cd src/BizHawk.Version cd src/BizHawk.Version
${commentUnless useCWDAsSource}dotnet build ${extraDotnetBuildFlags} dotnet build ${extraDotnetBuildFlags}
${commentUnless useCWDAsSource}cd ../.. cd ../..
Dist/Build${buildConfig}.sh ${extraDotnetBuildFlags} Dist/Build${buildConfig}.sh ${extraDotnetBuildFlags}
printf "NixHawk" >output/dll/custombuild.txt printf "NixHawk" >output/dll/custombuild.txt
Dist/Package.sh linux-x64 Dist/Package.sh linux-x64
@ -111,18 +97,19 @@ let
''; '';
dontPatchELF = true; dontPatchELF = true;
}; };
wrapperScripts = import Dist/wrapper-scripts.nix { wrapperScriptsFor = { hawkSourceInfo, bizhawkAssemblies }: import Dist/wrapper-scripts.nix {
inherit (pkgs) lib writeShellScriptBin writeText; 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; hawkVersion = hawkSourceInfo.version;
mono = monoFinal; mono = monoFinal;
}; };
mkWrapperWrapper = { pname, innerWrapper, desktopName }: stdenv.mkDerivation rec { mkWrapperWrapper = { hawkSourceInfo, bizhawkAssemblies, pname, innerWrapper, desktopName }: stdenv.mkDerivation rec {
inherit pname; inherit pname;
version = hawkSourceInfo.version; version = hawkSourceInfo.version;
exeName = "${pname}-${version}"; exeName = "${pname}-${version}";
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
buildInputs = [ bizhawk ]; buildInputs = [ bizhawkAssemblies ];
# there must be a helper for this somewhere... # there must be a helper for this somewhere...
dontUnpack = true; dontUnpack = true;
dontPatch = true; dontPatch = true;
@ -131,7 +118,7 @@ let
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
makeWrapper ${innerWrapper} $out/bin/${exeName} \ makeWrapper ${innerWrapper} $out/bin/${exeName} \
--set BIZHAWK_HOME ${bizhawk} --set BIZHAWK_HOME ${bizhawkAssemblies}
''; '';
dontFixup = true; dontFixup = true;
# desktopItems = [ (makeDesktopItem { # desktopItems = [ (makeDesktopItem {
@ -140,20 +127,56 @@ let
# inherit desktopName; # actually Name # inherit desktopName; # actually Name
# }) ]; # }) ];
}; };
in { buildDiscoHawkWrapperFor = { hawkSourceInfo, bizhawkAssemblies ? buildAssembliesFor hawkSourceInfo }: let
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 wrapperScripts = wrapperScriptsFor { inherit hawkSourceInfo bizhawkAssemblies; };
discohawk = mkWrapperWrapper { in mkWrapperWrapper {
inherit hawkSourceInfo bizhawkAssemblies;
pname = "discohawk-monort"; pname = "discohawk-monort";
innerWrapper = "${wrapperScripts.discoWrapper}/bin/discohawk-wrapper"; innerWrapper = "${wrapperScripts.discoWrapper}/bin/discohawk-wrapper";
desktopName = "DiscoHawk (Mono Runtime)"; 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"; pname = "emuhawk-monort";
innerWrapper = if forNixOS innerWrapper = if forNixOS
then "${wrapperScripts.wrapperScript}/bin/emuhawk-wrapper" then "${wrapperScripts.wrapperScript}/bin/emuhawk-wrapper"
else "${wrapperScripts.wrapperScriptNonNixOS}/bin/emuhawk-wrapper-non-nixos"; else "${wrapperScripts.wrapperScriptNonNixOS}/bin/emuhawk-wrapper-non-nixos";
desktopName = "EmuHawk (Mono Runtime)"; 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; mono = monoFinal;
} }