about summary refs log tree commit diff
path: root/pkgs/games/build-support
Commit message (Collapse)AuthorAgeFilesLines
* setup-hooks/fix-fmod: Patch all calls to system()aszlig2020-06-081-7/+10
| | | | | | | | | | | In newer versions of libfmod, there are two calls to system(), which cause the setup hook to fail, since it only expects one such call. Fortunately, we don't want libfmod to execute *any* external commands, so fixing this is rather easy by just making *all* calls to system() a no-op. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Also patch late-bound methodsaszlig2020-02-101-1/+2
| | | | | | | | | | | | | | This is something I encountered in Invisigun Heroes, where there is a virtual FileManagerAdapter class, which then gets bound to either the Desktop variant or any of the other ones. Since we always use the full path of the corresponding type/object, just adding the Callvirt to the opcodes we patch shouldn't interfere with any other games we patch that way and using an extra subcommand just for the Callvirt case would only add additional boilerplate for no additional benefits. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Fix SHA256 hashes for depsaszlig2019-02-131-2/+2
| | | | | | | | | | | I checked the archives against the previous versions and the contents match, however the archives themselves had differences with the file order so the hashes are different now. In the long term, we probably should use fetchzip instead so we don't get a hash mismatch if none of the actual contents change. Signed-off-by: aszlig <aszlig@nix.build>
* games: Add names for setup hooksaszlig2018-07-311-0/+2
| | | | | | | The name "hook" is a not very good derivation name to distinguish it from other hooks, so let's actually name them. Signed-off-by: aszlig <aszlig@nix.build>
* games: Move FMOD fixing from Bastion to setup hookaszlig2018-07-313-1/+73
| | | | | | | | | | | | | | | Thanks to @layus for pointing out that there is at least one other game (Epistory) which has the same FMOD issue as Bastion has. So I decided to move this into a setup hook that automatically discovers whether it's the affected FMOD version and NOPs out the calls to system(). In summary: If another game is affected, all that's needed now is to add fixFmodHook to nativeBuildInputs. Signed-off-by: aszlig <aszlig@nix.build> Cc: @layus
* games: Add a new gogUnpackHookaszlig2018-07-314-3/+85
| | | | | | | | | | | | | | | | | | This should make all the extra unpackCmd attributes for the GOG games superfluous and make the expression way less convoluted, especially the games based on Unity3D. Right now however, the gogUnpackHook is added to buildGame, which is used for all games, not only for the GOG ones. While it doesn't really hurt or affect non-GOG games, it's still part of the build closure so we might want to apply this to GOG only at some day. For that, we need to restructure our whole packaging layout, because we want to have a way to override buildGame only for a certain namespace but without introducing too much churn or duplicating things. Signed-off-by: aszlig <aszlig@nix.build> Cc: @layus
* monogame-patcher: Fix string antiquotationaszlig2018-07-221-1/+1
| | | | | | | Getting a message like "Type {thetype} not found." is not very helpful, so let's add the $ in front of the string. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Allow to define specific methodsaszlig2018-07-192-23/+49
| | | | | | | | | | | | | | So far we only matched a substring of a type, which isn't very exact of course. We also weren't able to specify the method to patch. Now the methods that are being patched can be specified by using Type::Method. If it's just Type without a method all the methods of the type and its subtypes are patched. I also added a small check to make sure that all of these methods were found, and if not an error is thrown. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Return exitcode 1 on CLI erroraszlig2018-07-192-2/+13
| | | | | | | | If there is a command line usage error, we really don't want the program to return exit status 0 (success), so let's actually set the return value on WithParsed(). Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Raise exception on no-opaszlig2018-07-191-1/+10
| | | | | | | We really want to make sure that things were actually patched, so just silently skipping everything is not an option. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Allow specifying extra assemblyaszlig2018-07-193-14/+58
| | | | | | | | If we want to replace a call with one that's not in a module which is currently referenced by the target file we now have another command line flag for replace-call (-a) where we can specify the additional DLL file. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Use cleanSource for the src attraszlig2018-07-191-2/+2
| | | | | | | | While there won't be any .git directories within ./src, I still create Vim swap files all the time when editing stuff. So let's make sure that those swap files are not included in the src input of the derivation. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Fix assembly search directoryaszlig2018-07-192-11/+16
| | | | | | | | | | | | | | By default the assemblies are searched in the current working directory, but when patching an assembly in some other directory than the current the patcher will fail to resolve assemblies residing beneath the target file. So we just add the directory of the target file to the search path. I also moved all of the assemblies in the test to be in a subdir so we can verify that this indeed works and we won't regress in the future. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Work around terminal width issueaszlig2018-07-192-1/+13
| | | | | | | | | | | | | | | | | | If the command is not executed inside a terminal the value of Console.WindowWidth is 0 and thus we will get an exception from CommandLineParser: Unhandled Exception: System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length at System.String.Substring ... at CommandLine.Text.HelpText.AddOption ... ... So let's initialize the parser with settings and if WindowWidth is 0 we just add 80 as the width. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Improve values for replace-callaszlig2018-07-192-5/+7
| | | | | | | | | | | | Using an IEnumerable for the search and replace arguments isn't really a very good idea, because it makes command line usage very annoying and messes up the usage description. I originally made this an IEnumerable because I wanted to have a way to specify multiple replacements, but we can simply run the patcher twice or more times. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Refactor method ref findingaszlig2018-07-195-67/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | So far we have searched for methods in two steps: First get all the types and then find all of the constructors or method definitions. The match for the actual method definition was done first for the type and then again for the full definition of the method/constructor. For the replace-call subcommand this also means that we don't have a very good way to find the type, because if we wanted to keep doing this in two steps we would need to parse the type name out of the one given as the replacement string in replace-call. So now we recurse through *all* the constructors and methods and do a full match against the specified replacement string, both for replace-call and for fix-filestreams. Compared to the implementation so far we also do this just once instead of every time we find a call or FileStream constructor. I also overhauled the way we do testing, because in the end writing tests using NUnit would introduce a lot of code churn because we need to make a lot of external calls. The shell is especially useful for exactly that and our tests are now just a plain shell script. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Restructure and add stub testsaszlig2018-07-195-30/+65
| | | | | | | | | | | | | Mainly this is so we can prepare for running unit tests, so we get the latest version of NUnit and run the console test runner. Currently there is only a dummy test which always succeeds, but it's there so that we can fill out the boilerplate later. I also moved the option definitions into a separate file so they don't clutter up the main file. Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Switch to MSBuildaszlig2018-07-194-27/+65
| | | | | | | | | | | | | | I really would have preferred a simple Makefile, but with that we can't use buildDotnetPackage and we also need to take care of butchering the dependencies manually. So I moved everything to src/ and added a csproj file to clean up most of the cruft and just use buildDotnetPackage with minimal attributes. In addition to that I also added assembly info, so that the command line help will show the proper author name, copyright, yaddayadda... Signed-off-by: aszlig <aszlig@nix.build>
* monogame-patcher: Add a replace-call subcommandaszlig2018-07-191-2/+61
| | | | | | | | | | | | | | | | | | | | | It's a very early version which I did for a Unity3d game and it *desperately* needs a cleanup. An example command line: monogame-patcher replace-call -i Assembly-CSharp.dll \ 'System.String UnityEngine.Application::get_dataPath()' \ 'System.String UnityEngine.Application::get_persistentDataPath()' \ IniParser SaveMeta Right now the replace-call subcommand has UnityEngine.Application hardcoded, so this won't work for other types than UnityEngine.Application. However, I'm going to refactor the whole patcher very soon and add some tests, so this whole mess will be cleaned up. Signed-off-by: aszlig <aszlig@nix.build>
* towerfall-ascension: Move patcher into own pkgaszlig2018-07-193-0/+141
| | | | | | | | | | | | The patcher using Cecil is now in its own derivation and can thus be easily added via nativeBuildInputs. Patching FileStream types is so common that it comes in handy for other games using Mono. I also improved the patcher a little bit so it accepts command line arguments and it's easier to add the types that needed to be patched directly via command line arguments. Signed-off-by: aszlig <aszlig@nix.build>
* games/build-unity: Add support for .app dirsaszlig2018-06-281-1/+6
| | | | | | | | | | | | | | | Some games (well, currently just one, Dungeons 3) come with a .app directory that contains additional game data which includes package .unity3d files. Such directories will be searched relative from the current working directory, so let's actually set the working directory to $out/share/something and copy the .app directory to that if it exists. Tested with Dungeons 3 and also with a few other Unity3d games to see whether they still work. Signed-off-by: aszlig <aszlig@nix.build>
* pkgs/games: Replace usages of mesa with libGLaszlig2018-04-211-2/+2
| | | | | | | | | | | | | This has been changed in NixOS/nixpkgs@6bf1421f13d667c2997b67728cf777c6, so let's change it here as well. Quote from the mentioned commit: Implement libGL as a symlink package which uses libraries from libglvnd and headers from Mesa (since ones from libglvnd are outdated). Signed-off-by: aszlig <aszlig@nix.build>
* build-game: Remove installCheckPhaseaszlig2018-02-221-31/+1
| | | | | | | | | | | | This is quite redundant because autoPatchelfHook already scans all shared objects and executables for dependencies and bails out with an error if a dependency isn't found, which is similar to what we're doing in installCheckPhase. Removing this should also speed up builds, especially those with lots of files. Signed-off-by: aszlig <aszlig@nix.build>
* build-game: Properly find sourceRootaszlig2018-02-221-6/+5
| | | | | | | | | | | | | | | | So far we only checked for the source root by checking only one level of directories, so for example if the source code is unpacked into something like "a/b/c" and only "c" contains files, the previous implementation would set the source root to be "a". In addition we didn't do a check on the type of the contents, so for example if the archive contains only *one* file, that *file* itself would be set as the source root and the chdir to that will fail later. What we do now is recursively search through directories in order to find the last directory that does not contain *only* a subdirectory. Signed-off-by: aszlig <aszlig@nix.build>
* build-unity: Properly re-add attributesaszlig2018-02-091-2/+2
| | | | | | | | A few attributes weren't re-added to the actual derivation, so for example whenever we add buildInputs to buildUnity the attribute would be completely ignored. Signed-off-by: aszlig <aszlig@nix.build>
* auto-patchelf: Move checkElfDep into buildGameaszlig2018-02-011-0/+7
| | | | | | | | Having a function in autoPatchelfHook that's unused inside the setup hook is a bit of weird, because the actual usage is within buildGame and thus it should stay there for now. Signed-off-by: aszlig <aszlig@nix.build>
* auto-patchelf: Move into pkgs/build-supportaszlig2018-02-013-155/+2
| | | | | | | | | This is really not game-specific, so let's put it at the top-level and also make sure we substitute all the commands we're using there, even though a few of them are in PATH of stdenv so that it will always work even when the programs available in stdenv should change someday. Signed-off-by: aszlig <aszlig@nix.build>
* auto-patchelf: Only search for deps with same archaszlig2018-02-011-4/+11
| | | | | | | | | | | | So far we only matched the file name of the dependency but not its architecture, so if for example there is one shared object for i686-linux and another one with the same name but for x86_64-linux, chances are that the wrong architecture is chosen. Now we're checking the architecture of the shared object file and only pick it, if it matches the architecture of the file to patchelf. Signed-off-by: aszlig <aszlig@nix.build>
* auto-patchelf: Clean up a bitaszlig2018-02-011-7/+11
| | | | | | | This makes sure that ldd doesn't print warnings like if the file isn't executable and also makes the status messages a bit more clear. Signed-off-by: aszlig <aszlig@nix.build>
* auto-patchelf: Fix adding env hookaszlig2018-02-011-1/+1
| | | | | | | | | | | | | | The semantics of adding env hooks has changed in NixOS/nixpkgs@7f3ca3e21a22fd3101b40cadb86899542dec2e35 so that it's now broken up into several hook variables (envBuildBuildHook, envBuildHostHook, envBuildTargetHook, envHostHostHook, envHostTargetHook and envTargetTargetHook). Fortunately commit NixOS/nixpkgs@a036473a0a0c6100fce316e1444fc33ec6674b adds a helper function (addEnvHooks) to deal this without referencing those hook variables directly and rather just providing an offset. Signed-off-by: aszlig <aszlig@nix.build>
* build-sandbox: Move to top-level build-supportaszlig2017-11-3011-1008/+2
| | | | | | | This is not only useful for packaging games, so let's make it available from the vuizvui scope, so we can use it from other packages as well. Signed-off-by: aszlig <aszlig@nix.build>
* pkgs/build-unity: Make saveDir optionalaszlig2017-11-211-3/+5
| | | | | | | | If the saveDir isn't set the game only gets access to all the saveDirs from other Unity games, so missing that attribute shouldn't be a deal breaker. Signed-off-by: aszlig <aszlig@nix.build>
* pkgs/build-unity: Add a saveDir attributeaszlig2017-11-211-2/+2
| | | | | | | | This is used for sandboxing and instead of letting all Unity games access the data of every other Unity game we now restrict it to its own save directory only. Signed-off-by: aszlig <aszlig@nix.build>
* pkgs/sandbox: Handle non-existing pathsaszlig2017-11-215-32/+59
| | | | | | | | | | | | | | | | | | We now distinguish between paths that have to exist and paths that are fine to skip during bind mounting. So far we had hard failures whenever a path that needed to be mounted didn't exist, for example something like $XDG_CONFIG_HOME/unity3d failed whenever the directory didn't exist. Apart from that we now have a more clean attribute structure for sandbox parameters, which are now: * paths.required: Created prior to bind-mounting * paths.wanted: Skipped if it doesn't exist * paths.runtimeVars: Extracted from PATH-like environment variables Signed-off-by: aszlig <aszlig@nix.build>
* pkgs/sandbox: Mount closure of /etc/staticaszlig2017-10-032-5/+45
| | | | | | | | We already mount /etc, but it isn't quite enough, because it contains files symlinked to /etc/static, which in turn is a store path so we need to mount the closure of that path as well. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/sandbox: Implement a path cacheaszlig2017-10-034-3/+53
| | | | | | | | First of all this is to bring down the amount of syscalls we're doing but it's also useful to avoid errors when we try to mount a path over an already mounted path. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/build-game: Enable sandbox by defaultaszlig2017-10-033-6/+13
| | | | | | | | | This is using buildSandbox with the addition of adding LD_LIBRARY_PATH to the default runtimePathVars. I've also renamed the attribute to be called runtimePathVars instead of runtimePathVariables, simply because it's shorter. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/sandbox: Mount paths from path-like variablesaszlig2017-10-038-29/+211
| | | | | | | | | | | | | | | | | | | | | On NixOS the LD_LIBRARY_PATH looks similar to this (depending on the configuration): /run/opengl-driver/lib:/run/opengl-driver-32/lib However, we don't have these paths available within the sandbox, because so far we've only used exportReferencesGraph to gather the runtime dependencies after the build has succeeded. This obviously doesn't take into account runtime dependencies from the system itself. We are now taking care of this by using the Nix store library to query the requisities of all the paths that are contained inside path-like variables (multiple paths delimited by colons) and mount them during sandbox setup. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/sandbox: Factor out setup routineaszlig2017-10-036-573/+609
| | | | | | | | | | This leaves sandbox.c with only the main() function and nothing else, so that whenever we have a lot of binaries to generate, the compilation time should be much lower now. The change doesn't change anything in functionality. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/sandbox: Prepare for querying runtime pathsaszlig2017-10-034-18/+49
| | | | | | | | | | We're now using a makefile for building the sandbox and use pkg-config to pass in the flags we need for compiling against lib(nix)store. Right now the sandbox itself doesn't do anything different because we're not actually using the (incomplete) code for querying the store. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/sandbox: Include basic runtime pathsaszlig2017-10-032-18/+112
| | | | | | | | | | | These paths are things such as /etc and /run but also the .Xauthority file, which contains the cookie to connect to the X server. What is still missing is access to the DRI libraries, which is a bit trickier, because we need to add those store paths at runtime and we need to also mount all of the dependencies. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/sandbox: Use own store path as root directoryaszlig2017-10-032-10/+9
| | | | | | | | | | | | | | | | | | | I've already pointed out in the previous commit that using /tmp for the root directory isn't a very good idea, mainly because we can't access sockets from /tmp (eg. the X server sockets). So what we're now doing is using the store path that contains the sandbox wrappers, because that very path won't be mounted into the sandbox anyway, so we get a free directory just as an entry point. This has the main advantage that we don't need to create any temporary directories which we later need to clean up nor do we need to assume that some paths might exist in the system. For example if we'd use /usr we still have /usr/bin/env on NixOS, but if that's going to go away in the future or we are on a distro that doesn't have it at all, the sandbox setup will fail. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/build-game: Introduce buildSandboxaszlig2017-10-035-118/+63
| | | | | | | | | | | | | | | | So far creating the sandbox has been a setup hook, however it's a bit ugly how we gathered the needed paths for the chroot file system by recursively searching for store paths. While I'd like to have the sandbox being built within the main derivation, it really isn't very practical when the build takes longer than 10 minutes. With this implementation however the sandbox builds really fast and we can also modify the sandbox without needing to rebuild a particular game. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/build-game: Add preliminary sandbox hookaszlig2017-10-033-3/+617
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is basically to make sure various games can't write to whatever they want in the file system, so it's not a complete sandboxing solution. Currently there's a drawback in that we can't easily determine the runtime dependencies while building a particular game, so we need to recursively dig through all referenced store paths to look them up. A better solution for this would be to gather the build time reference graph prior to building so that we can limit searching for these references within only the actual build outputs instead of churning through all inputs. In addition to that, we currently mount the namespaced root file system on top of /tmp, which makes the real /tmp unavailable to us. While in theory this shouldn't be a problem, it actually turns out it is indeed a problem if the application wants to connect to the X server socket, which is at something like /tmp/.X11-unix/X0 for display :0. Apart from these drawbacks we have a working solution for simple applications (not games, because they usually require X), which now get its own chroot with only the paths accessible that are strictly necessary. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/build-game: Add ALSA library to RT depsaszlig2017-09-131-2/+8
| | | | | | | | | Most older games don't cope very well with PulseAudio, so let's add ALSA so that a fallback is available. This is also very useful if withPulseAudio is set to false, because this would actually mean "no audio at all". Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/build-game: Add unzip to nativeBuildInputsaszlig2017-09-131-2/+2
| | | | | | | | | | | A lot of games come as a Zip archive, so let's add it to nativeBuildInputs by default so we no longer need to deal with that for every single game. This also removes that line from Invisigun Heroes, so the package now is pretty much minimal and very clean :-) Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/build-game: Try to evade tarbombsaszlig2017-09-131-1/+21
| | | | | | | | | | A lot of games (especially Unity games) come as a tarbomb, so in order to avoid having those files all over the place we now create an additional directory before unpack and set the sourceRoot to that if it's a tarbomb and if that's not the case set it to the single file within that directory. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/build-unity: Switch to using buildGameaszlig2017-09-131-23/+19
| | | | | | | | | | | Now we no longer need to invoke patchelf by ourselves and all of the dependencies are patched automatically. I've added gtk2-x11, gdk_pixbuf and glib to buildUnity as well, because after inspecting other Unity games they seem to require the same libraries as well. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/build-game: Add runtimeDependencies attributeaszlig2017-09-133-11/+23
| | | | | | | This allows us to add libraries to the RPATH despite being required by the respective game. By default there is only PulseAudio at the moment. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
* pkgs/games: Add a new buildGame functionaszlig2017-09-133-0/+178
| | | | | | | | | | | | | | | The main functionality for this function is to gather missing dependencies in ELF executables and shared libraries and using patchelf to set the right RPATH. All of the dependencies are searched based on what we have in one of the buildInputs variables, so all we need to do is list them in there. One thing that's still left to solve is adding libraries to the RPATH which are only required at runtime. An example for this would be the pulseaudio library. Signed-off-by: aszlig <aszlig@redmoonstudios.org>