From 7ee28c1ab981720deb5d295ecc8c15b3f4b18b85 Mon Sep 17 00:00:00 2001 From: James Groom Date: Sat, 2 Dec 2023 18:40:22 +0000 Subject: [PATCH] Nix expr: Add `libGL` to `buildInputs` on NixOS currently `libGL.so.1` just happens to be in the closure via `cairo`, but that's no longer the case in Nixpkgs 23.11 --- Dist/historical.nix | 1 + Dist/packages.nix | 11 +++++++---- default.nix | 20 +++++++++++++++----- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Dist/historical.nix b/Dist/historical.nix index 2e6027b172..3572f20f0a 100644 --- a/Dist/historical.nix +++ b/Dist/historical.nix @@ -207,6 +207,7 @@ in { hasFFmpegPatch_e68a49aa5 = isVersionAtLeast "2.9.2" version; # with e68a49aa5, downloading *and running* FFmpeg finally works; TODO use FFmpeg from Nixpkgs since it's a stable version (4.4.1) hasMiscTypeCheckerPatch_6afb3be98 = isVersionAtLeast "2.6.2" version; neededExtraManagedDeps = neededExtraManagedDepsApprox; + needsLibGLVND = false; # true iff not using nixGL (i.e. on NixOS) AND using the OpenGL renderer (the default option) needsSDL = isVersionAtLeast "2.9.2" version; nugetDeps = ./deps.nix; packageScriptNeeds7Zip = !isVersionAtLeast "2.6.3" version; diff --git a/Dist/packages.nix b/Dist/packages.nix index 29508c5412..be0bceea83 100644 --- a/Dist/packages.nix +++ b/Dist/packages.nix @@ -16,6 +16,7 @@ # makedeps , git # rundeps +, libGL , lua , mono , monoBasic @@ -63,7 +64,7 @@ }; genDepsHostTargetFor = { hawkSourceInfo, mono' ? mono }: [ lua mono' openal (lib.getOutput "out" zstd) ] ++ lib.optionals hawkSourceInfo.needsSDL [ SDL2 (lib.getOutput "out" udev) ] - ; + ++ lib.optional hawkSourceInfo.needsLibGLVND (lib.getOutput "out" libGL); /** * see splitReleaseArtifact re: outputs * and no you can't build only DiscoHawk and its deps; deal with it @@ -224,6 +225,7 @@ buildInstallable' = { hawkSourceInfo , bizhawkAssemblies + , forNixOS , pname , launchScriptAttrName , desktopName @@ -233,7 +235,7 @@ then lib.traceIf (hawkSourceInfo != null) "`hawkSourceInfo` passed to `build{EmuHawk,DiscoHawk}InstallableFor` will be ignored in favour of `bizhawkAssemblies.hawkSourceInfo`" bizhawkAssemblies else assert lib.assertMsg (hawkSourceInfo != null) "must pass either `hawkSourceInfo` or `bizhawkAssemblies` to `build{EmuHawk,DiscoHawk}InstallableFor`"; - buildAssembliesFor hawkSourceInfo; + buildAssembliesFor (lib.optionalAttrs forNixOS { needsLibGLVND = true; } // hawkSourceInfo); in buildInstallable { inherit desktopName pname; bizhawkAssemblies = bizhawkAssembliesFinal; @@ -287,10 +289,11 @@ in { buildDiscoHawkInstallableFor = { bizhawkAssemblies ? null , hawkSourceInfo ? null + , forNixOS ? true # currently only adds Mesa to buildInputs, and DiscoHawk doesn't need that, but it's propagated through here so the asms derivation can be shared between it and EmuHawk , desktopName ? "DiscoHawk (Mono Runtime)" , desktopIcon ? null }: buildInstallable' { - inherit bizhawkAssemblies desktopIcon desktopName hawkSourceInfo; + inherit bizhawkAssemblies desktopIcon desktopName forNixOS hawkSourceInfo; pname = "discohawk-monort"; launchScriptAttrName = "discohawk"; }; @@ -301,7 +304,7 @@ in { , desktopName ? "EmuHawk (Mono Runtime)" , desktopIcon ? null }: buildInstallable' { - inherit bizhawkAssemblies desktopIcon desktopName hawkSourceInfo; + inherit bizhawkAssemblies desktopIcon desktopName forNixOS hawkSourceInfo; pname = "emuhawk-monort"; launchScriptAttrName = if forNixOS then "emuhawk" else "emuhawkNonNixOS"; }; diff --git a/default.nix b/default.nix index fc5505ecd5..ea9af64745 100644 --- a/default.nix +++ b/default.nix @@ -30,6 +30,7 @@ in { , git ? pkgs.gitMinimal # only when building from-CWD (`-local`) # rundeps , coreutils ? pkgs.coreutils +, libGL ? pkgs.libGL , lua ? pkgs.lua54Packages.lua , mono ? null , nixGLChannel ? (pkgs.nixgl or import (fetchTarball "https://github.com/guibou/nixGL/archive/489d6b095ab9d289fe11af0219a9ff00fe87c7c5.tar.gz") {}) @@ -90,7 +91,7 @@ in { buildDotnetModule fetchpatch fetchzip hardLinkJoin launchScriptsFor makeDesktopItem releaseTagSourceInfos runCommand symlinkJoin writeShellScriptBin git - lua openal SDL2 udev zstd + libGL lua openal SDL2 udev zstd buildConfig doCheck emuhawkBuildFlavour extraDefines extraDotnetBuildFlags; mono = if mono != null then mono # allow older Mono if set explicitly @@ -109,7 +110,10 @@ in { inherit forNixOS; hawkSourceInfo = hawkSourceInfoDevBuild; }; - asmsFromReleaseArtifacts = lib.mapAttrs (_: pp.splitReleaseArtifact) releaseArtifactInfos; + 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; # 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 releasesEmuHawkInstallables = lib.pipe releaseFrags [ @@ -137,13 +141,19 @@ in { latestVersionFrag = lib.head releaseFrags; combined = pp // asmsFromReleaseArtifacts // releasesEmuHawkInstallables // { inherit depsForHistoricalRelease releaseTagSourceInfos; - bizhawkAssemblies = pp.buildAssembliesFor hawkSourceInfoDevBuild; - "bizhawkAssemblies-${latestVersionFrag}" = pp.buildAssembliesFor releaseTagSourceInfos."info-${latestVersionFrag}"; - discohawk = pp.buildDiscoHawkInstallableFor { hawkSourceInfo = hawkSourceInfoDevBuild; }; + bizhawkAssemblies = pp.buildAssembliesFor (fillTargetOSDifferences hawkSourceInfoDevBuild); + "bizhawkAssemblies-${latestVersionFrag}" = pp.buildAssembliesFor + (fillTargetOSDifferences releaseTagSourceInfos."info-${latestVersionFrag}"); + discohawk = pp.buildDiscoHawkInstallableFor { + inherit forNixOS; + hawkSourceInfo = hawkSourceInfoDevBuild; + }; "discohawk-${latestVersionFrag}" = pp.buildDiscoHawkInstallableFor { + inherit forNixOS; hawkSourceInfo = releaseTagSourceInfos."info-${latestVersionFrag}"; }; "discohawk-${latestVersionFrag}-bin" = pp.buildDiscoHawkInstallableFor { + inherit forNixOS; bizhawkAssemblies = asmsFromReleaseArtifacts."bizhawkAssemblies-${latestVersionFrag}-bin"; }; emuhawk = emuhawk-local;