summary refs log tree commit diff
path: root/pkgs/games/osu-lazer/default.nix
diff options
context:
space:
mode:
authoroxalica <oxalicc@pm.me>2020-04-12 02:12:04 +0800
committeroxalica <oxalicc@pm.me>2020-07-09 02:20:12 +0800
commita21ba99681b00a9deddbc16373ce9f78f9c83189 (patch)
tree8db4203833c9626a32233ae9e364b1d32d7525ce /pkgs/games/osu-lazer/default.nix
parentdc80d7bc4a244120b3d766746c41c0d9c5f81dfa (diff)
downloadnixpkgs-a21ba99681b00a9deddbc16373ce9f78f9c83189.tar
nixpkgs-a21ba99681b00a9deddbc16373ce9f78f9c83189.tar.gz
nixpkgs-a21ba99681b00a9deddbc16373ce9f78f9c83189.tar.bz2
nixpkgs-a21ba99681b00a9deddbc16373ce9f78f9c83189.tar.lz
nixpkgs-a21ba99681b00a9deddbc16373ce9f78f9c83189.tar.xz
nixpkgs-a21ba99681b00a9deddbc16373ce9f78f9c83189.tar.zst
nixpkgs-a21ba99681b00a9deddbc16373ce9f78f9c83189.zip
osu-lazer: init at 2020.707.0
Diffstat (limited to 'pkgs/games/osu-lazer/default.nix')
-rw-r--r--pkgs/games/osu-lazer/default.nix104
1 files changed, 104 insertions, 0 deletions
diff --git a/pkgs/games/osu-lazer/default.nix b/pkgs/games/osu-lazer/default.nix
new file mode 100644
index 00000000000..5351493a18b
--- /dev/null
+++ b/pkgs/games/osu-lazer/default.nix
@@ -0,0 +1,104 @@
+{ lib, stdenv, fetchFromGitHub, fetchurl, makeWrapper, makeDesktopItem, linkFarmFromDrvs
+, dotnet-sdk, dotnet-netcore, dotnetPackages
+, ffmpeg_4, alsaLib, SDL2, lttng-ust, numactl, alsaPlugins
+}:
+
+let
+  runtimeDeps = [
+    ffmpeg_4 alsaLib SDL2 lttng-ust numactl
+  ];
+
+  # https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#using-rids
+  runtimeId = "linux-x64";
+
+in stdenv.mkDerivation rec {
+  pname = "osu-lazer";
+  version = "2020.707.0";
+
+  src = fetchFromGitHub {
+    owner = "ppy";
+    repo = "osu";
+    rev = version;
+    sha256 = "0n270gv841567q1j3xj7hpnnqwbgj0yai5wf58kwj0f0spkcy8vz";
+  };
+
+  nativeBuildInputs = [ dotnet-sdk dotnetPackages.Nuget makeWrapper ];
+
+  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
+    export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
+
+    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
+
+    dotnet restore --source nixos osu.Desktop
+
+    runHook postConfigure
+  '';
+
+  buildPhase = ''
+    runHook preBuild
+    dotnet build osu.Desktop \
+      --no-restore \
+      --configuration Release \
+      -p:Version=${version}
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    dotnet publish osu.Desktop \
+      --no-build \
+      --configuration Release \
+      --no-self-contained \
+      --output $out/lib/osu
+    shopt -s extglob
+    rm -r $out/lib/osu/runtimes/!(${runtimeId})
+
+    makeWrapper $out/lib/osu/osu\! $out/bin/osu\! \
+      --set DOTNET_ROOT "${dotnet-netcore}" \
+      --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
+  '';
+
+  # 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 ];
+    maintainers = with maintainers; [ oxalica ];
+    platforms = [ "x86_64-linux" ];
+  };
+  passthru.updateScript = ./update.sh;
+}