2023-11-19 13:33:48 +00:00
{ pkgs ? import ( fetchTarball " h t t p s : / / g i t h u b . c o m / N i x O S / n i x p k g s / a r c h i v e / 2 3 . 0 5 . t a r . g z " ) { }
, lib ? pkgs . lib
2021-11-15 08:17:16 +00:00
, stdenv ? pkgs . stdenvNoCC
2023-11-19 13:33:48 +00:00
# infrastructure
2021-11-15 08:17:16 +00:00
, buildDotnetModule ? pkgs . buildDotnetModule
2023-11-21 04:15:37 +00:00
, dpkg ? pkgs . dpkg
2021-11-15 08:17:16 +00:00
, fetchFromGitHub ? pkgs . fetchFromGitHub
2023-11-19 13:33:48 +00:00
, fetchFromGitLab ? pkgs . fetchFromGitLab
, fetchpatch ? pkgs . fetchpatch
, fetchzip ? pkgs . fetchzip
, makeDesktopItem ? pkgs . makeDesktopItem
, mkNugetDeps ? pkgs . mkNugetDeps
, runCommand ? pkgs . runCommand
, symlinkJoin ? pkgs . symlinkJoin
, writeShellScript ? pkgs . writeShellScript
, writeShellScriptBin ? pkgs . writeShellScriptBin
, writeText ? pkgs . writeText
2021-11-15 08:17:16 +00:00
# source
2023-11-19 13:33:48 +00:00
, hawkSourceInfoDevBuild ? let # called "dev build", but you could pass whatever branch and commit you want here
version = " 2 . 9 . 2 - l o c a l " ; # used in default value of `BIZHAWK_DATA_HOME`, which distinguishes parallel installs' config and other data
in {
inherit version ;
2023-11-21 04:15:37 +00:00
src = builtins . path { path = ./. ; name = " B i z H a w k - ${ version } " ; } ; # source derivation; did have filter here for speed, but it wasn't faster and it wasn't correct and it couldn't be made correct and I'm mad
2022-03-08 00:17:18 +00:00
}
2021-11-15 08:17:16 +00:00
# makedeps
2023-11-19 13:33:48 +00:00
, dotnet-sdk_6 ? pkgs . dotnet-sdk_6
, dotnet-sdk_5 ? let result = builtins . tryEval pkgs . dotnet-sdk_5 ; in if result . success
then result . value
else ( import ( fetchTarball " h t t p s : / / g i t h u b . c o m / N i x O S / n i x p k g s / a r c h i v e / 5 2 3 4 f 4 c e 9 3 4 0 f f f b 7 0 5 b 9 0 8 f f f 4 8 9 6 f a e d d b 8 a 1 2 ^ . t a r . g z " ) { } ) . dotnet-sdk_5
, git ? pkgs . gitMinimal # only when building from-CWD (`-local`)
# rundeps
, coreutils ? pkgs . coreutils
, lua ? pkgs . lua54Packages . lua
2021-11-18 12:39:15 +00:00
, mono ? null
2023-11-19 13:33:48 +00:00
, nixGLChannel ? ( pkgs . nixgl or import ( fetchTarball " h t t p s : / / g i t h u b . c o m / g u i b o u / n i x G L / a r c h i v e / 4 8 9 d 6 b 0 9 5 a b 9 d 2 8 9 f e 1 1 a f 0 2 1 9 a 9 f f 0 0 f e 8 7 c 7 c 5 . t a r . g z " ) { } )
, nixGL ? nixGLChannel . auto . nixGLDefault
#, nixVulkan ? nixGLChannel.auto.nixVulkanNvidia
2021-11-15 08:17:16 +00:00
, openal ? pkgs . openal
2023-11-19 13:33:48 +00:00
, SDL2 ? pkgs . SDL2
, udev ? pkgs . udev
2022-08-17 10:28:58 +00:00
, zstd ? pkgs . zstd
2021-11-15 08:17:16 +00:00
# other parameters
, buildConfig ? " R e l e a s e " # "Debug"/"Release"
2023-11-19 13:33:48 +00:00
, debugPInvokes ? false # forwarded to Dist/launch-scripts.nix
, debugDotnetHostCrashes ? false # forwarded to Dist/launch-scripts.nix
2021-11-15 08:17:16 +00:00
, doCheck ? false # runs `Dist/BuildTest${buildConfig}.sh`
2023-11-19 13:33:48 +00:00
, emuhawkBuildFlavour ? " N i x H a w k "
, extraDefines ? " " # added to `<DefineConstants/>`, so ';'-separated
, extraDotnetBuildFlags ? " " # currently passed to EVERY `dotnet build` and `dotnet test` invocation (and does not replace the flags for parallel compilation added by default)
, forNixOS ? true
, initConfig ? { } # forwarded to Dist/launch-scripts.nix (see docs there)
} : let
2023-11-21 04:15:37 +00:00
isVersionAtLeast = lib . flip lib . versionAtLeast ; # I stand by this being the more useful param order w.r.t. currying
2023-11-19 13:33:48 +00:00
replaceDotWithUnderscore = s : lib . replaceStrings [ " . " ] [ " _ " ] s ;
/* * y o u c a n ' t a c t u a l l y m a k e h a r d l i n k s i n t h e s a n d b o x , s o t h i s j u s t c o p i e s , a n d w e ' l l r e l y o n N i x ' a u t o m a t i c d e d u p i n g */
hardLinkJoin =
{ name
, paths
, preferLocalBuild ? true
, allowSubstitutes ? false
, __contentAddressed ? false
} : runCommand name {
inherit __contentAddressed allowSubstitutes paths preferLocalBuild ;
passAsFile = [ " p a t h s " ] ;
} ''
mkdir - p $ out
for d in $ ( cat $ pathsPath ) ; do
cd " $ d "
find . - type d - exec mkdir - p " $ o u t / { } " \ ;
for f in $ ( find . - type f ) ; do cp - T " $ ( r e a l p a t h " $ f " ) " " $ o u t / $ f " ; done
done
2021-11-15 08:17:16 +00:00
'' ;
2023-11-19 13:33:48 +00:00
inherit ( import Dist/historical.nix {
inherit lib
2023-11-21 04:15:37 +00:00
isVersionAtLeast replaceDotWithUnderscore
2023-11-19 13:33:48 +00:00
fetchFromGitHub fetchFromGitLab mkNugetDeps
dotnet-sdk_5 dotnet-sdk_6 ;
} ) depsForHistoricalRelease populateHawkSourceInfo releaseArtifactInfos releaseFrags releaseTagSourceInfos ;
launchScriptsFor = bizhawkAssemblies : isManualLocalBuild : import Dist/launch-scripts.nix {
inherit lib
writeShellScript writeText
bizhawkAssemblies nixGL
debugPInvokes debugDotnetHostCrashes initConfig isManualLocalBuild ;
mkfifo = coreutils ;
mktemp = coreutils ;
2021-11-15 08:17:16 +00:00
} ;
2023-11-19 13:33:48 +00:00
pp = import Dist/packages.nix {
inherit lib stdenv
populateHawkSourceInfo replaceDotWithUnderscore
buildDotnetModule fetchpatch fetchzip hardLinkJoin launchScriptsFor makeDesktopItem
releaseTagSourceInfos runCommand symlinkJoin writeShellScriptBin
git
lua openal SDL2 udev zstd
buildConfig doCheck emuhawkBuildFlavour extraDefines extraDotnetBuildFlags ;
mono = if mono != null
then mono # allow older Mono if set explicitly
2023-11-21 04:15:37 +00:00
else if isVersionAtLeast " 6 . 1 2 . 0 . 1 5 1 " pkgs . mono . version
2023-11-19 13:33:48 +00:00
then pkgs . mono
else lib . trace " p r o v i d e d M o n o t o o o l d , u s i n g M o n o f r o m N i x p k g s 2 3 . 0 5 "
( import ( fetchTarball " h t t p s : / / g i t h u b . c o m / N i x O S / n i x p k g s / a r c h i v e / 2 3 . 0 5 . t a r . g z " ) { } ) . mono ;
2023-11-21 04:15:37 +00:00
monoBasic = fetchzip {
url = " h t t p s : / / d o w n l o a d . m o n o - p r o j e c t . c o m / r e p o / d e b i a n / p o o l / m a i n / m / m o n o - b a s i c / l i b m o n o - m i c r o s o f t - v i s u a l b a s i c 1 0 . 0 - c i l _ 4 . 7 - 0 x a m a r i n 3 + d e b i a n 9 b 1 _ a l l . d e b " ;
nativeBuildInputs = [ dpkg ] ;
hash = " s h a 2 5 6 - 2 m 1 F w p D x z q V X R 6 G U B 3 o F u T q I X C d e / m s b + t g 8 v 6 l I N 6 s = " ;
# tried and failed building from source, following https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=mono-basic
} ;
2021-12-02 05:41:15 +00:00
} ;
2023-11-19 13:33:48 +00:00
emuhawk-local = pp . buildEmuHawkInstallableFor {
inherit forNixOS ;
hawkSourceInfo = hawkSourceInfoDevBuild ;
2022-01-20 02:26:54 +00:00
} ;
2023-11-19 13:33:48 +00:00
asmsFromReleaseArtifacts = lib . mapAttrs ( _ : pp . splitReleaseArtifact ) releaseArtifactInfos ;
# the asms for from-CWD and latest release from-source are exposed below as `bizhawkAssemblies` and `bizhawkAssemblies-latest`, respectively
# apart from that, no `asmsFromSource`, since if you're only after the assets you might as well use the release artifact
2023-11-21 04:15:37 +00:00
releasesEmuHawkInstallables = lib . pipe releaseFrags [
( builtins . map ( versionFrag : [
2023-11-19 13:33:48 +00:00
( {
name = " e m u h a w k - ${ versionFrag } " ;
value = pp . buildEmuHawkInstallableFor {
inherit forNixOS ;
hawkSourceInfo = releaseTagSourceInfos . " i n f o - ${ versionFrag } " ;
} ;
} )
( {
name = " e m u h a w k - ${ versionFrag } - b i n " ;
value = pp . buildEmuHawkInstallableFor {
inherit forNixOS ;
bizhawkAssemblies = asmsFromReleaseArtifacts . " b i z h a w k A s s e m b l i e s - ${ versionFrag } - b i n " ;
} ;
} )
2023-11-21 04:15:37 +00:00
] ) )
lib . concatLists
lib . listToAttrs
( lib . filterAttrs ( name : value : lib . hasSuffix " - b i n " name
|| isVersionAtLeast " 2 . 6 " value . hawkSourceInfo . version ) )
] ;
2023-11-19 13:33:48 +00:00
latestVersionFrag = lib . head releaseFrags ;
combined = pp // asmsFromReleaseArtifacts // releasesEmuHawkInstallables // {
inherit depsForHistoricalRelease releaseTagSourceInfos ;
bizhawkAssemblies = pp . buildAssembliesFor hawkSourceInfoDevBuild ;
" b i z h a w k A s s e m b l i e s - ${ latestVersionFrag } " = pp . buildAssembliesFor releaseTagSourceInfos . " i n f o - ${ latestVersionFrag } " ;
discohawk = pp . buildDiscoHawkInstallableFor { hawkSourceInfo = hawkSourceInfoDevBuild ; } ;
" d i s c o h a w k - ${ latestVersionFrag } " = pp . buildDiscoHawkInstallableFor {
hawkSourceInfo = releaseTagSourceInfos . " i n f o - ${ latestVersionFrag } " ;
2022-03-08 00:17:18 +00:00
} ;
2023-11-19 13:33:48 +00:00
" d i s c o h a w k - ${ latestVersionFrag } - b i n " = pp . buildDiscoHawkInstallableFor {
bizhawkAssemblies = asmsFromReleaseArtifacts . " b i z h a w k A s s e m b l i e s - ${ latestVersionFrag } - b i n " ;
2022-03-08 00:17:18 +00:00
} ;
2023-11-19 13:33:48 +00:00
emuhawk = emuhawk-local ;
launchScriptsForLocalBuild = launchScriptsFor emuhawk-local . assemblies true ;
2022-03-08 00:17:18 +00:00
} ;
2023-11-19 13:33:48 +00:00
in combined // lib . listToAttrs ( lib . concatLists ( builtins . map
( f : [
{ name = f " l a t e s t - b i n " ; value = combined . ${ f " ${ latestVersionFrag } - b i n " } ; }
{ name = f " l a t e s t " ; value = combined . ${ f latestVersionFrag } ; }
] )
2023-11-20 02:22:33 +00:00
[ ( s : " b i z h a w k A s s e m b l i e s - ${ s } " ) ( s : " e m u h a w k - ${ s } " ) ( s : " d i s c o h a w k - ${ s } " ) ] ) )