Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vvvvvv: init at 2.3-git-2020-11-22 #79068

Closed
wants to merge 6 commits into from
Closed

Conversation

anna328p
Copy link
Member

@anna328p anna328p commented Feb 2, 2020

Adds a package for VVVVVV, a platform game based on inverting gravity.

Motivation for this change

Adds the game VVVVVV to nixpkgs.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notes

Fixed version of #78319 which was broken after a bad merge into my nixpkgs fork.

@sikmir
Copy link
Member

sikmir commented Feb 2, 2020

Could you please squash commits into one?

@nh2
Copy link
Contributor

nh2 commented Feb 2, 2020

For reference, this is a replacement for the previous PR #78319.

CCing people who commented there so they don't miss out on notifications: @leo60228 @jakobrs

@leo60228
Copy link
Member

leo60228 commented Feb 2, 2020

Should there not be separate pkgs.vvvvvvMakeAndPlay and pkgs.vvvvvvFull attributes?

@jakobrs
Copy link
Contributor

jakobrs commented Feb 2, 2020

Idea: If someone implements the ability to load data.zip from a custom location, the binary could be factored out into a separate derivation, which might be redistributable.

/nix/store/...-data.zip             definitely unfree
/nix/store/...-vvvvvv-full-bin-...  unfreeRedistributable
/nix/store/...-vvvvvv-full-...      unfree, I think

The last of the three derivations would simply be a wrapper script that calls vvvvvv-bin with the right assets.

#!/bin/sh
${vvvvvvBin}/bin/VVVVVV --assets ${dataZip}

@leo60228
Copy link
Member

leo60228 commented Feb 2, 2020

I can do this when I get home in about 30 minutes.

@jakobrs
Copy link
Contributor

jakobrs commented Feb 2, 2020

On the legal side of things:

@TerryCavanagh, are you OK with us redistributing the full-version binary without redistributing the assets?

@leo60228
Copy link
Member

leo60228 commented Feb 2, 2020

diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp
index 2a1d2df..a7db5ca 100644
--- a/desktop_version/src/FileSystemUtils.cpp
+++ b/desktop_version/src/FileSystemUtils.cpp
@@ -39,7 +39,7 @@ void PLATFORM_getOSDirectory(char* output);
 void PLATFORM_migrateSaveData(char* output);
 void PLATFORM_copyFile(const char *oldLocation, const char *newLocation);
 
-int FILESYSTEM_init(char *argvZero)
+int FILESYSTEM_init(char *argvZero, char *dataPath)
 {
 	char output[MAX_PATH];
 	int mkdirResult;
@@ -79,9 +79,7 @@ int FILESYSTEM_init(char *argvZero)
 	}
 
 	/* Mount the stock content last */
-	strcpy(output, PHYSFS_getBaseDir());
-	strcat(output, "data.zip");
-	if (!PHYSFS_mount(output, NULL, 1))
+	if (!PHYSFS_mount(dataPath, NULL, 1))
 	{
 		puts("Error: data.zip missing!");
 		puts("You do not have data.zip!");
diff --git a/desktop_version/src/FileSystemUtils.h b/desktop_version/src/FileSystemUtils.h
index d3c551e..404896b 100644
--- a/desktop_version/src/FileSystemUtils.h
+++ b/desktop_version/src/FileSystemUtils.h
@@ -6,7 +6,7 @@
 
 #include "tinyxml.h"
 
-int FILESYSTEM_init(char *argvZero);
+int FILESYSTEM_init(char *argvZero, char *dataPath);
 void FILESYSTEM_deinit();
 
 char *FILESYSTEM_getUserSaveDirectory();
diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp
index 4dba0fa..76c79f3 100644
--- a/desktop_version/src/main.cpp
+++ b/desktop_version/src/main.cpp
@@ -44,7 +44,7 @@ entityclass obj;
 
 int main(int argc, char *argv[])
 {
-    if(!FILESYSTEM_init(argv[0]))
+    if(!FILESYSTEM_init(argv[0], argv[1]))
     {
         return 1;
     }
@@ -55,9 +55,9 @@ int main(int argc, char *argv[])
         SDL_INIT_GAMECONTROLLER
     );
 
-    if (argc > 2 && strcmp(argv[1], "-renderer") == 0)
+    if (argc > 3 && strcmp(argv[2], "-renderer") == 0)
     {
-        SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, argv[2], SDL_HINT_OVERRIDE);
+        SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, argv[3], SDL_HINT_OVERRIDE);
     }
 
     NETWORK_init();

@jakobrs
Copy link
Contributor

jakobrs commented Feb 2, 2020

Remember that you’ll probably want to make sure that that can be merged into upstream, as otherwise this package will have to be marked as modified.

From the license:

Altered source/binary versions must be plainly marked as such, and must not be misrepresented as being the original software.

Edit: What I mean is that it is important that the syntax is compatible with the old invocation syntax, as otherwise it probably won’t be merged into VVVVVV itself.

@leo60228
Copy link
Member

leo60228 commented Feb 2, 2020

TerryCavanagh/VVVVVV#139

@TerryCavanagh
Copy link

@jakobrs Yep, it's fine to distribute the full version binary without the data.zip assets included.

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please squash the commits as well please:

git reset HEAD^^^
git add pkgs/
git commit --amend --no-edit
git push .. .. --forcce

@leo60228
Copy link
Member

leo60228 commented Feb 2, 2020

The PR adding -assets was just merged.

@anna328p
Copy link
Member Author

anna328p commented Feb 2, 2020

Should there not be separate pkgs.vvvvvvMakeAndPlay and pkgs.vvvvvvFull attributes?

can't that be done in all-packages.nix?

vvvvvvFull = callPackage ../games/vvvvvv { fullGame = true };

@anna328p
Copy link
Member Author

anna328p commented Feb 2, 2020

here's the problem:

the officially distributed data.zip is the same as the Make and Play Edition data.zip, they have the same hash. the only difference between these two versions of the game is the flags used to build the game. if -DMAKEANDPLAY is set then the game runs in the Make and Play mode.

if the binary version is distributed with the make and play flag disabled, you can use the zip from the make and play version to play the game. therefore, if you have the full game, you must supply the zip yourself and the binary is built locally as it is not allowed to be redistributed. if you do not have the full game, you get the make and play binary which can be redistributed with the make and play zip (again, this is the same as the standard zip)

@anna328p
Copy link
Member Author

anna328p commented Feb 2, 2020

Could you please squash commits into one?

Doesn't Github have an option to automatically do that when merging a pull request?

@leo60228
Copy link
Member

leo60228 commented Feb 3, 2020

Doesn't Github have an option to automatically do that when merging a pull request?

Yes, but it doesn't follow the commit naming scheme used for nixpkgs.

@jakobrs
Copy link
Contributor

jakobrs commented Feb 3, 2020

That problem (with the Make and Play edition using the same zip file) already exists:

nix-env -iA nixpkgs.vvvvvv      # Fetches the data.zip for you
nix-env -iA nixpkgs.vvvvvvFull  # Uses the data.zip fetched in the previous step

The obvious solution is either not to fetch the data.zip in either case, or somehow change the hash of the data.zip file.

@anna328p
Copy link
Member Author

anna328p commented Feb 3, 2020

That problem (with the Make and Play edition using the same zip file) already exists:

nix-env -iA nixpkgs.vvvvvv      # Fetches the data.zip for you
nix-env -iA nixpkgs.vvvvvvFull  # Uses the data.zip fetched in the previous step

The obvious solution is either not to fetch the data.zip in either case, or somehow change the hash of the data.zip file.

This problem already exists outside nixpkgs though; anyone can take the publicly available source and the publicly available make and play edition data.zip, and compile a complete version of the game.

@leo60228
Copy link
Member

leo60228 commented Feb 3, 2020

Maybe have fetchurl rename the Make & Play data.zip so they have different hashes?

@leo60228
Copy link
Member

leo60228 commented Feb 3, 2020

We could also do postFetch = "echo nixpkgs | zip -z $out";.

@leo60228
Copy link
Member

leo60228 commented Feb 3, 2020

Yep, this seems to work:

let
  dataZip = if fullGame then requireFile {                                                                                                   
    # the data file for the full game                                                                                                        
    name = "data.zip";                                                                                                                       
    sha256 = "1q2pzscrglmwfgdl8yj300wymwskh51iq66l4xcd0qk0q3g3rbkg";                                                                         
    message = ''                                                                                                                             
      In order to install VVVVVV, you must first download the game's                                                                         
      data file (data.zip) as it is not released freely.                                                                                     
      Once you have downloaded the file, place it in your current                                                                            
      directory, use the following command and re-run the installation:                                                                      
      nix-prefetch-url file://\$PWD/data.zip                                                                                                 
    '';                                                                                                                                      
  } else fetchurl {                                                                                                                          
    # the data file for the free Make and Play edition                                                                                       
    url = https://thelettervsixtim.es/makeandplay/data.zip;                                                                                  
    sha256 = "0vnb4zyzp8jpayxrgs6mw98wxpcpqdcfx04j1g5s0hm378xwmxm6";                                                                         
    postFetch = "echo nixpkgs | ${zip}/bin/zip -z $out";                                                                                     
  };                                                                                                                                         

@leo60228
Copy link
Member

leo60228 commented Feb 3, 2020

@TerryCavanagh The license only applies to the binaries, right? That would make this hack of adding a zip file comment to the Make & Play data.zip so it has a different hash allowed. That's necessary because Nix treats files with the same name and hash as being the same file, so there's otherwise no way to distribute the Make & Play data.zip without also distributing the full game's data.zip. As a demonstration of this problem:

nix-env -iA nixos.vvvvvvFull # errors, no data.zip
nix-env -iA nixos.vvvvvv # downloads binaries and data.zip
nix-env -iA nixos.vvvvvvFull # succeeds, downloads binaries and uses data.zip already on system

Adding a zip file comment while downloading data.zip would cause it to have a different hash, solving this problem. This clause is worrying me:

Altered source/binary versions must be plainly marked as such, and must not be misrepresented as being the original software.

@anna328p
Copy link
Member Author

Actually, v2.3's release date got bumped to October 1st.

The current master branch of the repository builds cleanly and has some substantial feature improvements over version 2.2. I'll bump the package to the latest revision and make the changes required to separate the full game and Make and Play Mode.

anna328p and others added 6 commits July 28, 2020 21:28
Adds a package for VVVVVV, a platform game based on inverting gravity.
- changed version to be a date instead of a fragment of the commit id
- quoted homepage url
- if user does not own the full game, build the redistributable "make
  and play version" instead
- using sourceRoot instead of manually changing directory
homepage = "https://thelettervsixtim.es";
license = if fullGame then licenses.unfree else licenses.unfreeRedistributable;
maintainers = [ maintainers.dkudriavtsev ];
platforms = [ platforms.linux platforms.darwin ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes [[string]] we want [string]

Suggested change
platforms = [ platforms.linux platforms.darwin ];
platforms = platforms.linux ++ platforms.darwin;

SDL2 SDL2_mixer
] + stdenv.lib.optionalPlatform stdenv.lib.platforms.darwin [ Foundation ];

sourceRoot = "source/desktop_version";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sourceRoot = "source/desktop_version";
sourceRoot = "source/desktop_version";

nativeBuildInputs = [ cmake ninja ];
buildInputs = [
SDL2 SDL2_mixer
] + stdenv.lib.optionalPlatform stdenv.lib.platforms.darwin [ Foundation ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optionalPlatform doesn't exist, i think you want

Suggested change
] + stdenv.lib.optionalPlatform stdenv.lib.platforms.darwin [ Foundation ];
] + stdenv.lib.optionals stdenv.hostPlatform.isDarwin [ Foundation ];

};

# if the user does not own the full game, build the Make and Play edition
flags = if fullGame then [] else [ "-DMAKEANDPLAY" ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flags = if fullGame then [] else [ "-DMAKEANDPLAY" ];
flags = lib.optionals fullGame [ "-DMAKEANDPLAY" ];

'';
} else fetchurl {
# the data file for the free Make and Play edition
url = https://thelettervsixtim.es/makeandplay/data.zip;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a versioned link?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data.zip has never changed since it was first introduced in 2014. Due to compatibility and the fact that this is an 11-year-old game, it probably won't ever be changed either. (But new zips will probably be introduced.)

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please squash the commits together and address the reviewer feedback.

@anna328p
Copy link
Member Author

I plan on completely reworking this PR once 2.3 releases.

@anna328p anna328p marked this pull request as draft November 29, 2020 08:29
@leo60228
Copy link
Member

I'm pretty sure that due to the requireFile and fetchurl having the same hash the requireFile will just get the data.zip from the binary cache without prompting the user.

@anna328p
Copy link
Member Author

I'm pretty sure that due to the requireFile and fetchurl having the same hash the requireFile will just get the data.zip from the binary cache without prompting the user.

Is there no way to have a license-restricted requireFile?

@@ -24712,6 +24712,8 @@ in
libpng = libpng12;
};

vvvvvv = callPackage ../games/vvvvvv { };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vvvvvv = callPackage ../games/vvvvvv { };
vvvvvv = callPackage ../games/vvvvvv {
inherit (darwin.apple_sdk.frameworks) Foundation;
};

@stale
Copy link

stale bot commented Jun 26, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 26, 2021
@anna328p
Copy link
Member Author

Still planning to work on this as soon as 2.3 releases.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 26, 2021
@SuperSandro2000 SuperSandro2000 added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md and removed 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md labels Jun 26, 2021
@dasJ
Copy link
Member

dasJ commented Sep 1, 2021

2.3.1 is released now

@anna328p
Copy link
Member Author

Just saw this. I plan to work on this

@leo60228 leo60228 mentioned this pull request Nov 5, 2021
11 tasks
@SuperSamus SuperSamus mentioned this pull request Jun 3, 2022
13 tasks
@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 10, 2022
@Mic92
Copy link
Member

Mic92 commented Dec 18, 2022

Closing because of lack of activity from the author. Please re-open if you plan to work on this.

@Mic92 Mic92 closed this Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet