3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/games/osu-lazer/default.nix

126 lines
3.4 KiB
Nix
Raw Normal View History

2020-04-11 19:12:04 +01:00
{ lib, stdenv, fetchFromGitHub, fetchurl, makeWrapper, makeDesktopItem, linkFarmFromDrvs
2021-02-01 18:13:12 +00:00
, dotnetCorePackages, dotnetPackages, cacert
2020-04-11 19:12:04 +01:00
, ffmpeg_4, alsaLib, SDL2, lttng-ust, numactl, alsaPlugins
}:
let
runtimeDeps = [
ffmpeg_4 alsaLib SDL2 lttng-ust numactl
];
2021-02-01 18:13:12 +00:00
dotnet-sdk = dotnetCorePackages.sdk_5_0;
dotnet-net = dotnetCorePackages.net_5_0;
2020-04-11 19:12:04 +01:00
# https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#using-rids
runtimeId = "linux-x64";
in stdenv.mkDerivation rec {
pname = "osu-lazer";
2021-03-24 19:01:00 +00:00
version = "2021.323.0";
2020-04-11 19:12:04 +01:00
src = fetchFromGitHub {
owner = "ppy";
repo = "osu";
rev = version;
2021-03-24 19:01:00 +00:00
sha256 = "zoJGCsnjvXzPxGy85YsP+WbaN7p8EwcTqiCEX/czMR8=";
2020-04-11 19:12:04 +01:00
};
patches = [ ./bypass-tamper-detection.patch ];
patchFlags = [ "--binary" "-p1" ];
2021-02-01 18:13:12 +00:00
nativeBuildInputs = [
dotnet-sdk dotnetPackages.Nuget makeWrapper
# FIXME: Without `cacert`, we will suffer from https://github.com/NuGet/Announcements/issues/49
cacert
];
2020-04-11 19:12:04 +01:00
nugetDeps = linkFarmFromDrvs "${pname}-nuget-deps" (import ./deps.nix {
fetchNuGet = { name, version, sha256 }: fetchurl {
name = "nuget-${name}-${version}.nupkg";
url = "https://www.nuget.org/api/v2/package/${name}/${version}";
inherit sha256;
};
});
configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d)
export DOTNET_CLI_TELEMETRY_OPTOUT=1
2020-12-08 19:02:20 +00:00
export DOTNET_NOLOGO=1
2020-04-11 19:12:04 +01:00
nuget sources Add -Name nixos -Source "$PWD/nixos"
nuget init "$nugetDeps" "$PWD/nixos"
# FIXME: https://github.com/NuGet/Home/issues/4413
mkdir -p $HOME/.nuget/NuGet
cp $HOME/.config/NuGet/NuGet.Config $HOME/.nuget/NuGet
2020-12-08 19:02:20 +00:00
dotnet restore --source "$PWD/nixos" osu.Desktop --runtime ${runtimeId}
2020-04-11 19:12:04 +01:00
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
dotnet build osu.Desktop \
--no-restore \
--configuration Release \
2020-12-08 19:02:20 +00:00
--runtime ${runtimeId} \
2020-04-11 19:12:04 +01:00
-p:Version=${version}
runHook postBuild
'';
installPhase = ''
runHook preInstall
dotnet publish osu.Desktop \
--no-build \
--configuration Release \
2020-12-08 19:02:20 +00:00
--runtime ${runtimeId} \
2020-04-11 19:12:04 +01:00
--no-self-contained \
--output $out/lib/osu
makeWrapper $out/lib/osu/osu\! $out/bin/osu\! \
2021-02-01 18:13:12 +00:00
--set DOTNET_ROOT "${dotnet-net}" \
2020-04-11 19:12:04 +01:00
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}"
for i in 16 32 48 64 96 128 256 512 1024; do
install -D ./assets/lazer.png $out/share/icons/hicolor/''${i}x$i/apps/osu\!.png
done
cp -r ${makeDesktopItem {
desktopName = "osu!";
name = "osu";
exec = "osu!";
icon = "osu!";
comment = meta.description;
type = "Application";
categories = "Game;";
}}/share/applications $out/share
runHook postInstall
'';
2020-12-08 19:02:20 +00:00
fixupPhase = ''
runHook preFixup
cp -f ${./osu.runtimeconfig.json} "$out/lib/osu/osu!.runtimeconfig.json"
ln -sft $out/lib/osu ${SDL2}/lib/libSDL2${stdenv.hostPlatform.extensions.sharedLibrary}
runHook postFixup
'';
2020-04-11 19:12:04 +01:00
# Strip breaks the executable.
dontStrip = true;
meta = with lib; {
description = "Rhythm is just a *click* away";
homepage = "https://osu.ppy.sh";
license = with licenses; [
mit
cc-by-nc-40
unfreeRedistributable # osu-framework contains libbass.so in repository
];
2020-04-11 19:12:04 +01:00
maintainers = with maintainers; [ oxalica ];
platforms = [ "x86_64-linux" ];
};
passthru.updateScript = ./update.sh;
}