2024-04-12 04:52:45 +00:00
{ system ? builtins . currentSystem
2024-06-02 00:41:05 +00:00
, pkgs ? import ( builtins . fetchTarball {
2024-06-01 01:26:29 +00:00
url = " 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 4 . 0 5 . t a r . g z " ;
sha256 = " 1 l r 1 h 3 5 p r q k d 1 m k m z r i w l p v x c b 3 4 k m h c 9 d n r 4 8 g k m 8 h h 0 8 9 h i f m x " ;
2024-04-12 04:52:45 +00:00
} ) { inherit system ; }
2023-11-19 13:33:48 +00:00
, 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
2024-02-12 20:38:03 +00:00
, dotnet-sdk_8 ? pkgs . dotnet-sdk_8
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
2024-06-02 00:41:05 +00:00
else ( import ( fetchzip {
url = " 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 / a 8 f 5 7 5 9 9 5 4 3 4 6 9 5 a 1 0 b 5 7 4 d 3 5 c a 5 1 b 0 f 2 6 a e 9 0 4 9 . t a r . g z " ; # commit immediately before .NET 5 was removed
hash = " s h a 5 1 2 - 3 y s J j K K 1 l Y V 1 r / z L o h y u D 1 f i K + 8 T D 3 M M A 3 T r X 9 f b 4 2 n K q z f G G W 6 2 A o m 7 l t i y y x b V b B Y O C X U y 4 1 Z 5 Y 0 j 2 V O x R K w = = " ;
2024-04-12 04:52:45 +00:00
} ) { inherit system ; } ) . dotnet-sdk_5
2023-11-19 13:33:48 +00:00
, git ? pkgs . gitMinimal # only when building from-CWD (`-local`)
# rundeps
, coreutils ? pkgs . coreutils
2024-09-21 17:19:25 +00:00
, gnome-themes-extra ? pkgs . gnome3 . gnome-themes-extra
2024-09-21 16:05:27 +00:00
, gtk2-x11 ? pkgs . gtk2-x11
2024-07-01 12:28:23 +00:00
, kate ? pkgs . kate . overrideAttrs ( oldAttrs : {
patches = ( oldAttrs . patches or [ ] ) ++ [ ( fetchpatch {
url = " h t t p s : / / i n v e n t . k d e . o r g / u t i l i t i e s / k a t e / - / c o m m i t / 9 d d f 4 f 0 c 9 e b 3 c 2 6 a 0 a b 3 3 c 8 6 2 d 2 b 1 6 1 b c b d c 6 a 6 e . p a t c h " ; # Fix name of OmniSharp LSP binary
hash = " s h a 2 5 6 - a 2 K q o x u u V h f A Q U J A 3 / y E Q b 1 Q C o a 1 J C v L z 7 B Z Z n S L n z I = " ;
} ) ] ;
} )
2024-03-07 03:11:13 +00:00
, libgdiplus ? pkgs . libgdiplus
2023-12-02 18:40:22 +00:00
, libGL ? pkgs . libGL
2023-11-19 13:33:48 +00:00
, lua ? pkgs . lua54Packages . lua
2021-11-18 12:39:15 +00:00
, mono ? null
2024-06-02 00:41:05 +00:00
, nixGLChannel ? ( pkgs . nixgl or import ( fetchzip {
2024-04-12 04:52:45 +00:00
url = " 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 " ;
2024-06-02 00:41:05 +00:00
hash = " s h a 5 1 2 - G v V 7 0 7 f t L v E 0 M C T f M J b / M 8 6 S 2 N x f 3 v a i + H P w q 0 Q v J y l m M B w l i q Y x / n W 8 X 2 j a 2 r u O H z a w 3 M X X m A x j n v 5 M M U n 0 7 w = = " ;
2024-04-12 04:52:45 +00:00
} ) { inherit system ; } )
2023-11-19 13:33:48 +00:00
, nixGL ? nixGLChannel . auto . nixGLDefault
2024-07-01 12:28:23 +00:00
, omnisharp-roslyn ? pkgs . omnisharp-roslyn
2023-11-19 13:33:48 +00:00
#, 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
2023-11-25 14:56:06 +00:00
, doCheck ? true # runs `Dist/BuildTest${buildConfig}.sh`
2023-11-19 13:33:48 +00:00
, 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)
2024-08-17 08:12:19 +00:00
, profileManagedCalls ? false # forwarded to Dist/launch-scripts.nix
2023-11-19 13:33:48 +00:00
} : 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
2024-02-12 20:38:03 +00:00
dotnet-sdk_5 dotnet-sdk_6 dotnet-sdk_8 ;
2023-11-19 13:33:48 +00:00
} ) depsForHistoricalRelease populateHawkSourceInfo releaseArtifactInfos releaseFrags releaseTagSourceInfos ;
launchScriptsFor = bizhawkAssemblies : isManualLocalBuild : import Dist/launch-scripts.nix {
inherit lib
writeShellScript writeText
bizhawkAssemblies nixGL
2024-08-17 08:12:19 +00:00
debugPInvokes debugDotnetHostCrashes initConfig isManualLocalBuild profileManagedCalls ;
2023-11-19 13:33:48 +00:00
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
2024-09-21 17:19:25 +00:00
gnome-themes-extra gtk2-x11 libgdiplus libGL lua openal SDL2 udev zstd
2024-07-29 11:00:59 +00:00
buildConfig doCheck extraDefines extraDotnetBuildFlags ;
2024-12-31 06:51:06 +00:00
mono = lib . recursiveUpdate { meta . mainProgram = " m o n o " ; } ( if mono != null
2023-11-19 13:33:48 +00:00
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 "
2024-06-02 00:41:05 +00:00
( import ( fetchzip {
2024-04-12 04:52:45 +00:00
url = " 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 " ;
2024-06-02 00:41:05 +00:00
hash = " s h a 5 1 2 - R E P J 9 f R K x T e f v h 1 d 2 5 M l o T 4 b X J I f x I + 1 E v f V W q 6 4 4 T z v + n u q 2 B m i G M i B N m B k y N 9 U T 5 f l 2 t d j q G l i y e 3 g Z G a I G g = = " ;
2024-12-31 06:51:06 +00:00
} ) { inherit system ; } ) . 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 ] ;
2024-06-02 00:41:05 +00:00
hash = " s h a 5 1 2 - b P X b s V r V i H A J z 6 P W u r y o 9 H A 6 N l v 0 b N q g c 7 2 p N K M / M U Q M 7 J T U c f M 0 V D U z k z 8 v z X S q p / n t 2 L l A O I q I s S 5 D 5 i B I v Q = = " ;
2023-11-21 04:15:37 +00:00
# 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-12-02 18:40:22 +00:00
fillTargetOSDifferences = hawkSourceInfo : lib . optionalAttrs forNixOS { needsLibGLVND = true ; } // hawkSourceInfo ; # don't like this, but the alternative is including `forNixOS` in `hawkSourceInfo` directly
asmsFromReleaseArtifacts = lib . mapAttrs
( _ : a : pp . splitReleaseArtifact ( a // { hawkSourceInfo = fillTargetOSDifferences a . hawkSourceInfo ; } ) )
releaseArtifactInfos ;
2023-11-19 13:33:48 +00:00
# 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 // {
2024-07-29 11:04:26 +00:00
inherit depsForHistoricalRelease populateHawkSourceInfo releaseTagSourceInfos ;
2023-12-02 18:40:22 +00:00
bizhawkAssemblies = pp . buildAssembliesFor ( fillTargetOSDifferences hawkSourceInfoDevBuild ) ;
" b i z h a w k A s s e m b l i e s - ${ latestVersionFrag } " = pp . buildAssembliesFor
( fillTargetOSDifferences releaseTagSourceInfos . " i n f o - ${ latestVersionFrag } " ) ;
discohawk = pp . buildDiscoHawkInstallableFor {
inherit forNixOS ;
hawkSourceInfo = hawkSourceInfoDevBuild ;
} ;
2023-11-19 13:33:48 +00:00
" d i s c o h a w k - ${ latestVersionFrag } " = pp . buildDiscoHawkInstallableFor {
2023-12-02 18:40:22 +00:00
inherit forNixOS ;
2023-11-19 13:33:48 +00:00
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 {
2023-12-02 18:40:22 +00:00
inherit forNixOS ;
2023-11-19 13:33:48 +00:00
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 ;
2024-07-01 12:28:23 +00:00
IDEs = {
kate = [ kate omnisharp-roslyn ] ;
} ;
2023-11-19 13:33:48 +00:00
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 } " ) ] ) )