|
| 1 | +{ |
| 2 | + cargo, |
| 3 | + gamescope, |
| 4 | + godot_4_4, |
| 5 | + hwdata, |
| 6 | + lib, |
| 7 | + mesa-demos, |
| 8 | + nix-update-script, |
| 9 | + pkg-config, |
| 10 | + rustPlatform, |
| 11 | + stdenv, |
| 12 | + udev, |
| 13 | + upower, |
| 14 | + withDebug ? false, |
| 15 | +}: |
| 16 | + |
| 17 | +stdenv.mkDerivation (finalAttrs: { |
| 18 | + pname = "opengamepadui"; |
| 19 | + version = "latest"; |
| 20 | + |
| 21 | + buildType = if withDebug then "debug" else "release"; |
| 22 | + |
| 23 | + src = ../..; |
| 24 | + |
| 25 | + cargoDeps = rustPlatform.fetchCargoVendor { |
| 26 | + inherit (finalAttrs) src; |
| 27 | + sourceRoot = "OpenGamepadUI/${finalAttrs.cargoRoot}"; |
| 28 | + hash = "sha256-vgaa7Pe0lksiGEpQbn2he5CzhVWoHUSPuXqCwSkoDco="; |
| 29 | + }; |
| 30 | + cargoRoot = "extensions"; |
| 31 | + |
| 32 | + nativeBuildInputs = [ |
| 33 | + cargo |
| 34 | + godot_4_4 |
| 35 | + pkg-config |
| 36 | + rustPlatform.cargoSetupHook |
| 37 | + ]; |
| 38 | + |
| 39 | + dontStrip = withDebug; |
| 40 | + |
| 41 | + env = |
| 42 | + let |
| 43 | + versionAndRelease = lib.splitString "-" godot_4_4.version; |
| 44 | + in |
| 45 | + { |
| 46 | + GODOT = lib.getExe godot_4_4; |
| 47 | + GODOT_VERSION = lib.elemAt versionAndRelease 0; |
| 48 | + GODOT_RELEASE = lib.elemAt versionAndRelease 1; |
| 49 | + EXPORT_TEMPLATE = "${godot_4_4.export-template}/share/godot/export_templates"; |
| 50 | + BUILD_TYPE = "${finalAttrs.buildType}"; |
| 51 | + }; |
| 52 | + |
| 53 | + makeFlags = [ "PREFIX=$(out)" ]; |
| 54 | + |
| 55 | + buildFlags = [ "build" ]; |
| 56 | + |
| 57 | + preBuild = '' |
| 58 | + # Godot looks for export templates in HOME |
| 59 | + export HOME=$(mktemp -d) |
| 60 | + mkdir -p $HOME/.local/share/godot/ |
| 61 | + ln -s "$EXPORT_TEMPLATE" "$HOME"/.local/share/godot/ |
| 62 | + make clean |
| 63 | + ''; |
| 64 | + |
| 65 | + postInstall = |
| 66 | + let |
| 67 | + runtimeDependencies = [ |
| 68 | + gamescope |
| 69 | + hwdata |
| 70 | + mesa-demos |
| 71 | + udev |
| 72 | + upower |
| 73 | + ]; |
| 74 | + in |
| 75 | + '' |
| 76 | + # The Godot binary looks in "../lib" for gdextensions |
| 77 | + mkdir -p $out/share/lib |
| 78 | + mv $out/share/opengamepadui/*.so $out/share/lib |
| 79 | + patchelf --add-rpath ${lib.makeLibraryPath runtimeDependencies} $out/share/lib/*.so |
| 80 | + ''; |
| 81 | + |
| 82 | + passthru.updateScript = nix-update-script { }; |
| 83 | + |
| 84 | + meta = { |
| 85 | + description = "Open source gamepad-native game launcher and overlay"; |
| 86 | + homepage = "https://github.com/ShadowBlip/OpenGamepadUI"; |
| 87 | + license = lib.licenses.gpl3Only; |
| 88 | + platforms = [ "x86_64-linux" ]; |
| 89 | + maintainers = with lib.maintainers; [ shadowapex ]; |
| 90 | + mainProgram = "opengamepadui"; |
| 91 | + }; |
| 92 | +}) |
0 commit comments