From d80eeaea473d9caf1ef1fd7853f95ab4984fb0ab Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Sun, 5 Jul 2020 17:29:17 +0200 Subject: [PATCH 1/2] endgame-singularity: 0.30c -> 1.00 --- pkgs/games/endgame-singularity/default.nix | 50 +++++++++------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/pkgs/games/endgame-singularity/default.nix b/pkgs/games/endgame-singularity/default.nix index 46f21629ca36..c6355d05fa1f 100644 --- a/pkgs/games/endgame-singularity/default.nix +++ b/pkgs/games/endgame-singularity/default.nix @@ -1,46 +1,36 @@ -{ stdenv, fetchurl, unzip, python2 }: +{ stdenv +, fetchurl +, fetchFromGitHub +, unzip +, python3 +}: -python2.pkgs.buildPythonApplication rec { +python3.pkgs.buildPythonApplication rec { pname = "endgame-singularity"; - version = "0.30c"; - format = "other"; + version = "1.00"; srcs = [ - (fetchurl { - url = "http://www.emhsoft.com/singularity/singularity-${version}-src.tar.gz"; - sha256 = "13zjhf67gmla67nkfpxb01rxs8j9n4hs0s4n9lnnq4zgb709yxgl"; + (fetchFromGitHub { + owner = "singularity"; + repo = "singularity"; + rev = "v${version}"; + sha256 = "0ndrnxwii8lag6vrjpwpf5n36hhv223bb46d431l9gsigbizv0hl"; }) (fetchurl { url = "http://www.emhsoft.com/singularity/endgame-singularity-music-007.zip"; sha256 = "0vf2qaf66jh56728pq1zbnw50yckjz6pf6c6qw6dl7vk60kkqnpb"; }) ]; - sourceRoot = "."; + sourceRoot = "source"; nativeBuildInputs = [ unzip ]; # The music is zipped - propagatedBuildInputs = with python2.pkgs; [ pygame numpy ]; + propagatedBuildInputs = with python3.pkgs; [ pygame numpy polib ]; - # This is not an error: it needs both compilation rounds - buildPhase = '' - ${python2.interpreter} -m compileall "singularity-${version}" - ${python2.interpreter} -O -m compileall "singularity-${version}" - ''; - - installPhase = '' - install -Dm755 "singularity-${version}/singularity.py" "$out/share/singularity.py" - install -Dm644 "singularity-${version}/singularity.pyo" "$out/share/singularity.pyo" - install -Dm644 "singularity-${version}/singularity.pyc" "$out/share/singularity.pyc" - cp -R "singularity-${version}/code" "singularity-${version}/data" "$out/share/" - cp -R "endgame-singularity-music-007" "$out/share/music" - ''; - - # Tell it where to find python libraries - # Also cd to the same directory as the code, since it uses relative paths - postFixup = '' - makeWrapper "${python2.interpreter}" "$out/bin/endgame-singularity" \ - --set PYTHONPATH "$PYTHONPATH" \ - --run "cd \"$out/share\"" \ - --add-flags "$out/share/singularity.py" + # Add the music + postInstall = '' + cp -R "../endgame-singularity-music-007" \ + "$(echo $out/lib/python*/site-packages/singularity)/music" + # ↑ we cannot glob on [...]/music, it doesn't exist yet ''; meta = { From c823b4c374599508b3c95b3357da03e9f51f3221 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Sun, 5 Jul 2020 17:37:04 +0200 Subject: [PATCH 2/2] endgame-singularity: add option to disable the default music pack It's the heaviest part of the game. People may not want to have it take space or may want to use their own music. --- pkgs/games/endgame-singularity/default.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/games/endgame-singularity/default.nix b/pkgs/games/endgame-singularity/default.nix index c6355d05fa1f..4e855dbd053f 100644 --- a/pkgs/games/endgame-singularity/default.nix +++ b/pkgs/games/endgame-singularity/default.nix @@ -3,6 +3,7 @@ , fetchFromGitHub , unzip , python3 +, enableDefaultMusicPack ? true }: python3.pkgs.buildPythonApplication rec { @@ -16,18 +17,19 @@ python3.pkgs.buildPythonApplication rec { rev = "v${version}"; sha256 = "0ndrnxwii8lag6vrjpwpf5n36hhv223bb46d431l9gsigbizv0hl"; }) - (fetchurl { + ] ++ stdenv.lib.optional enableDefaultMusicPack ( + fetchurl { url = "http://www.emhsoft.com/singularity/endgame-singularity-music-007.zip"; sha256 = "0vf2qaf66jh56728pq1zbnw50yckjz6pf6c6qw6dl7vk60kkqnpb"; - }) - ]; + } + ); sourceRoot = "source"; nativeBuildInputs = [ unzip ]; # The music is zipped propagatedBuildInputs = with python3.pkgs; [ pygame numpy polib ]; # Add the music - postInstall = '' + postInstall = stdenv.lib.optionalString enableDefaultMusicPack '' cp -R "../endgame-singularity-music-007" \ "$(echo $out/lib/python*/site-packages/singularity)/music" # ↑ we cannot glob on [...]/music, it doesn't exist yet