From 44db586e8c2411d9282ef204b1b748993d4f57f2 Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Wed, 6 Jan 2021 23:55:24 +0100 Subject: [PATCH] openhexagon: Init at 1.92b --- default.nix | 2 + .../SSVJsonCpp-install-include-not-src.patch | 10 ++ .../SSVLuaWrapper-patch-include-paths.patch | 27 +++++ .../SSVOpenHexagon-Profiles-in-home-dir.patch | 99 +++++++++++++++++++ pkgs/openhexagon/default.nix | 17 ++++ pkgs/openhexagon/openhexagon.nix | 85 ++++++++++++++++ pkgs/openhexagon/ssventitysystem.nix | 36 +++++++ pkgs/openhexagon/ssvjsoncpp.nix | 26 +++++ pkgs/openhexagon/ssvluawrapper.nix | 33 +++++++ pkgs/openhexagon/ssvmenusystem.nix | 22 +++++ pkgs/openhexagon/ssvstart.nix | 46 +++++++++ pkgs/openhexagon/ssvutils.nix | 22 +++++ pkgs/openhexagon/ssvutilsjson.nix | 38 +++++++ 13 files changed, 463 insertions(+) create mode 100644 pkgs/openhexagon/SSVJsonCpp-install-include-not-src.patch create mode 100644 pkgs/openhexagon/SSVLuaWrapper-patch-include-paths.patch create mode 100644 pkgs/openhexagon/SSVOpenHexagon-Profiles-in-home-dir.patch create mode 100644 pkgs/openhexagon/default.nix create mode 100644 pkgs/openhexagon/openhexagon.nix create mode 100644 pkgs/openhexagon/ssventitysystem.nix create mode 100644 pkgs/openhexagon/ssvjsoncpp.nix create mode 100644 pkgs/openhexagon/ssvluawrapper.nix create mode 100644 pkgs/openhexagon/ssvmenusystem.nix create mode 100644 pkgs/openhexagon/ssvstart.nix create mode 100644 pkgs/openhexagon/ssvutils.nix create mode 100644 pkgs/openhexagon/ssvutilsjson.nix diff --git a/default.nix b/default.nix index 1afb98d..e2f9051 100644 --- a/default.nix +++ b/default.nix @@ -15,4 +15,6 @@ rec { }; flatery-icon-theme = callPackage ./pkgs/icon-theme/flatery-icon-theme.nix {}; + + openhexagon = callPackage ./pkgs/openhexagon/default.nix {}; } diff --git a/pkgs/openhexagon/SSVJsonCpp-install-include-not-src.patch b/pkgs/openhexagon/SSVJsonCpp-install-include-not-src.patch new file mode 100644 index 0000000..17ff4fb --- /dev/null +++ b/pkgs/openhexagon/SSVJsonCpp-install-include-not-src.patch @@ -0,0 +1,10 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 916e49f..4674424 100755 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -43,4 +43,4 @@ else() + install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION lib LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + endif() + +-install(DIRECTORY ${SRC_DIR} DESTINATION .) ++install(DIRECTORY ${INC_DIR} DESTINATION .) diff --git a/pkgs/openhexagon/SSVLuaWrapper-patch-include-paths.patch b/pkgs/openhexagon/SSVLuaWrapper-patch-include-paths.patch new file mode 100644 index 0000000..437d358 --- /dev/null +++ b/pkgs/openhexagon/SSVLuaWrapper-patch-include-paths.patch @@ -0,0 +1,27 @@ +diff --git a/cmake/modules/FindLUA.cmake b/cmake/modules/FindLUA.cmake +index afd8dbc..14205ec 100755 +--- a/cmake/modules/FindLUA.cmake ++++ b/cmake/modules/FindLUA.cmake +@@ -1,4 +1,4 @@ +-FIND_PATH(LUA_INCLUDE_DIR lua5.1/lua.hpp ++FIND_PATH(LUA_INCLUDE_DIR lua.hpp + PATHS "${PROJECT_SOURCE_DIR}/../lua/" + PATH_SUFFIXES include/ lua/ lua/include/ ./ + "${PROJECT_SOURCE_DIR}/extlibs/lua/" +diff --git a/include/SSVLuaWrapper/LuaContext/LuaContext.h b/include/SSVLuaWrapper/LuaContext/LuaContext.h +index eed4f3c..bff3ef6 100755 +--- a/include/SSVLuaWrapper/LuaContext/LuaContext.h ++++ b/include/SSVLuaWrapper/LuaContext/LuaContext.h +@@ -46,9 +46,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + extern "C" + { +-#include +-#include +-#include ++#include ++#include ++#include + } + + diff --git a/pkgs/openhexagon/SSVOpenHexagon-Profiles-in-home-dir.patch b/pkgs/openhexagon/SSVOpenHexagon-Profiles-in-home-dir.patch new file mode 100644 index 0000000..d2c619e --- /dev/null +++ b/pkgs/openhexagon/SSVOpenHexagon-Profiles-in-home-dir.patch @@ -0,0 +1,99 @@ +diff --git a/src/SSVOpenHexagon/Core/main.cpp b/src/SSVOpenHexagon/Core/main.cpp +index 7e3448f4..0c3a3f1e 100755 +--- a/src/SSVOpenHexagon/Core/main.cpp ++++ b/src/SSVOpenHexagon/Core/main.cpp +@@ -4,6 +4,9 @@ + + #include + #include ++#include ++#include ++#include + #include + #include + #include "SSVOpenHexagon/Online/Online.h" +@@ -18,12 +21,24 @@ using namespace ssvu; + using namespace ssvu::FileSystem; + using namespace hg; + ++static ++const char* getProfileFolder() { ++ char* path = new char[256]; ++ strcpy(path, std::getenv("HOME")); ++ strcat(path, "/.config/OpenHexagon/Profiles/"); ++ return path; ++} ++ + void createProfilesFolder() + { +- if(exists("Profiles/")) return; ++ const char* profileFolder = getProfileFolder(); ++ std::cout << "Profile folder: " << profileFolder << std::endl; ++ if(exists(profileFolder)) return; + + log("Profiles folder does not exist, creating", "CreateProfilesFolder"); +- createFolder("Profiles/"); ++ char command[512]; ++ sprintf(command, "mkdir -p \"%s\"", profileFolder); ++ system(command); + } + + int main(int argc, char* argv[]) +diff --git a/src/SSVOpenHexagon/Global/Assets.cpp b/src/SSVOpenHexagon/Global/Assets.cpp +index e008024d..340c74fe 100755 +--- a/src/SSVOpenHexagon/Global/Assets.cpp ++++ b/src/SSVOpenHexagon/Global/Assets.cpp +@@ -4,6 +4,8 @@ + + #include + #include ++#include ++#include + #include + #include + #include +@@ -24,9 +26,17 @@ using namespace ssvu; + using namespace ssvuj; + using namespace ssvu::FileSystem; + ++static ++const char* getProfileFolder() { ++ char* path = new char[256]; ++ strcpy(path, std::getenv("HOME")); ++ strcat(path, "/.config/OpenHexagon/Profiles/"); ++ return path; ++} ++ + namespace hg + { +- AssetManager assetManager; ++ AssetManager assetManager; + map musicDataMap; + map styleDataMap; + map levelDataMap; +@@ -130,9 +140,10 @@ namespace hg + } + void loadProfiles() + { +- for(auto filePath : getScan("Profiles/", ".json")) ++ const char* profileFolder = getProfileFolder(); ++ for(auto filePath : getScan(profileFolder, ".json")) + { +- string fileName{getNameFromPath(filePath, "Profiles/", ".json")}; ++ string fileName{getNameFromPath(filePath, profileFolder, ".json")}; + + ProfileData profileData{loadProfileFromJson(getRootFromFile(filePath))}; + profileDataMap.insert(make_pair(profileData.getName(), profileData)); +@@ -234,10 +245,10 @@ namespace hg + + void setCurrentProfile(const string& mName) { currentProfilePtr = &profileDataMap.find(mName)->second; } + ProfileData& getCurrentProfile() { return *currentProfilePtr; } +- string getCurrentProfileFilePath() { return "Profiles/" + currentProfilePtr->getName() + ".json"; } ++ string getCurrentProfileFilePath() { return getProfileFolder() + currentProfilePtr->getName() + ".json"; } + void createProfile(const string& mName) + { +- ofstream o{"Profiles/" + mName + ".json"}; ++ ofstream o{getProfileFolder() + mName + ".json"}; + Json::Value root; + Json::StyledStreamWriter writer; + diff --git a/pkgs/openhexagon/default.nix b/pkgs/openhexagon/default.nix new file mode 100644 index 0000000..738581f --- /dev/null +++ b/pkgs/openhexagon/default.nix @@ -0,0 +1,17 @@ +{ callPackage }: + +callPackage ./openhexagon.nix rec { + ssvjsoncpp = callPackage ./ssvjsoncpp.nix {}; + ssvutils = callPackage ./ssvutils.nix {}; + ssvluawrapper = callPackage ./ssvluawrapper.nix {}; + ssvmenusystem = callPackage ./ssvmenusystem.nix {}; + ssvutilsjson = callPackage ./ssvutilsjson.nix { + inherit ssvutils ssvjsoncpp; + }; + ssvstart = callPackage ./ssvstart.nix { + inherit ssvutils ssvjsoncpp ssvutilsjson; + }; + ssventitysystem = callPackage ./ssventitysystem.nix { + inherit ssvutils; + }; +} diff --git a/pkgs/openhexagon/openhexagon.nix b/pkgs/openhexagon/openhexagon.nix new file mode 100644 index 0000000..8345bc7 --- /dev/null +++ b/pkgs/openhexagon/openhexagon.nix @@ -0,0 +1,85 @@ +{ stdenv, fetchgit, makeWrapper, + cmake, + lua5_1, + sfml, + sparsehash, + ssvjsoncpp, + ssvutils, + ssvluawrapper, + ssvmenusystem, + ssvutilsjson, + ssvstart, + ssventitysystem, + rsync, +}: + +stdenv.mkDerivation rec { + pname = "OpenHexagon"; + version = "1.92b"; + + src = fetchgit { + url = "https://github.com/SuperV1234/SSVOpenHexagon"; + rev = "refs/tags/${version}"; + deepClone = true; + sha256 = "0qg7zxjswplzxnp6pmimvyly68zk3pd8jbv6a1ywv8jrfrdfpah1"; + }; + + binpkg = builtins.fetchTarball { + url = "https://vittorioromeo.info/Downloads/OpenHexagon/Linux/OpenHexagonV1.92.tar.gz"; + sha256 = "08rv97kr4cix2zshmi9avs92x5cryhg9f18abhpqbrpcr0mrganh"; + }; + + nativeBuildInputs = [ + cmake + makeWrapper + ]; + + buildInputs = [ + lua5_1 + sfml + sparsehash + ssvjsoncpp + ssvutils + ssvluawrapper + ssvmenusystem + ssvutilsjson + ssvstart + ssventitysystem + ]; + + preConfigure = '' + rm -r ./extlibs/* + ln -s ${ssventitysystem}/share ./extlibs/${ssventitysystem.pname}; + ln -s ${ssvjsoncpp}/share ./extlibs/${ssvjsoncpp.pname}; + ln -s ${ssvmenusystem}/share ./extlibs/${ssvmenusystem.pname}; + ln -s ${ssvstart}/share ./extlibs/${ssvstart.pname}; + ln -s ${ssvutils}/share ./extlibs/${ssvutils.pname}; + ln -s ${ssvutilsjson}/share ./extlibs/${ssvutilsjson.pname}; + ln -s ${ssvluawrapper}/share ./extlibs/${ssvluawrapper.pname}; + ''; + + patches = [ + ./SSVOpenHexagon-Profiles-in-home-dir.patch + ]; + + cmakeFlags = [ + "-DLUA_INCLUDE_DIR=${lua5_1}/include" + ]; + + installPhase = '' + install -Dm755 SSVOpenHexagon $out/bin/openhexagon + mkdir -p $out/share/OpenHexagon + cp -r ${src}/_RELEASE/{config.json,ConfigOverrides} $out/share/OpenHexagon + cp -r ${binpkg}/{Assets,Packs} $out/share/OpenHexagon + ''; + + postFixup = '' + wrapProgram "$out/bin/openhexagon" --run "cd $out/share/OpenHexagon/" + ''; + + meta = with stdenv.lib; { + description = "C++14 FOSS clone of Super Hexagon"; + homepage = "https://openhexagon.org/"; + license = licenses.afl3; + }; +} diff --git a/pkgs/openhexagon/ssventitysystem.nix b/pkgs/openhexagon/ssventitysystem.nix new file mode 100644 index 0000000..e6bd7da --- /dev/null +++ b/pkgs/openhexagon/ssventitysystem.nix @@ -0,0 +1,36 @@ +{ stdenv, fetchFromGitHub, cmake, ssvutils, sparsehash }: + +stdenv.mkDerivation rec { + pname = "SSVEntitySystem"; + version = "2013.06.14"; + + src = fetchFromGitHub { + owner = "SuperV1234"; + repo = pname; + rev = "ebb1b5121910304f84a8270f1941bf0a68d5d5d3"; + sha256 = "0ni424m31pys8gjvkhspdq437s4hvmhd4bh9qa6y7ql60wwjhyi5"; + }; + + nativeBuildInputs = [ + cmake + ]; + + cmakeFlags = [ + "-DSSVUTILS_INCLUDE_DIR=${ssvutils}/include" + ]; + + preConfigure = '' + rm -r ./extlibs/* + ln -s ${ssvutils}/share ./extlibs/SSVUtils; + ''; + + postInstall = '' + mkdir -p $out/share/cmake/modules + cp ${src}/cmake/modules/FindSSVEntitySystem.cmake $out/share/cmake/modules + ''; + + buildInputs = [ + ssvutils + sparsehash + ]; +} diff --git a/pkgs/openhexagon/ssvjsoncpp.nix b/pkgs/openhexagon/ssvjsoncpp.nix new file mode 100644 index 0000000..baa38a1 --- /dev/null +++ b/pkgs/openhexagon/ssvjsoncpp.nix @@ -0,0 +1,26 @@ +{ stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + pname = "SSVJsonCpp"; + version = "2013.06.14"; + + src = fetchFromGitHub { + owner = "SuperV1234"; + repo = pname; + rev = "cdae6add9a7181d29d44375909336079c549824e"; + sha256 = "0csysjddp2ifi535n8h5gd8agf2jsvqkjkvvad7ihbp7hkq4ihsg"; + }; + + patches = [ + ./SSVJsonCpp-install-include-not-src.patch + ]; + + postInstall = '' + mkdir -p $out/share/cmake/modules + cp ${src}/cmake/modules/FindSSVJsonCpp.cmake $out/share/cmake/modules + ''; + + nativeBuildInputs = [ + cmake + ]; +} diff --git a/pkgs/openhexagon/ssvluawrapper.nix b/pkgs/openhexagon/ssvluawrapper.nix new file mode 100644 index 0000000..14041cc --- /dev/null +++ b/pkgs/openhexagon/ssvluawrapper.nix @@ -0,0 +1,33 @@ +{ stdenv, fetchFromGitHub, cmake, lua5_1 }: + +stdenv.mkDerivation rec { + pname = "SSVLuaWrapper"; + version = "2013.06.14"; + + src = fetchFromGitHub { + owner = "SuperV1234"; + repo = pname; + rev = "decb0ee9971b0fd340386b7c95697e3eb3039ee5"; + sha256 = "1444x0vks3rhmgsrkd0avxss8rv0izm2b5wq03nw5p3fipw03sdx"; + }; + + nativeBuildInputs = [ + cmake + ]; + + patches = [ + ./SSVLuaWrapper-patch-include-paths.patch + ]; + + cmakeFlags = [ + "-DLUA_INCLUDE_DIR=${lua5_1}/include" + ]; + + + postInstall = '' + mkdir -p $out/share/cmake/modules + cp ${src}/cmake/modules/Find${pname}.cmake $out/share/cmake/modules + ''; + + buildInputs = [ lua5_1 ]; +} diff --git a/pkgs/openhexagon/ssvmenusystem.nix b/pkgs/openhexagon/ssvmenusystem.nix new file mode 100644 index 0000000..1e0dd43 --- /dev/null +++ b/pkgs/openhexagon/ssvmenusystem.nix @@ -0,0 +1,22 @@ +{ stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + pname = "SSVMenuSystem"; + version = "2013.06.11"; + + src = fetchFromGitHub { + owner = "SuperV1234"; + repo = pname; + rev = "5a49ad194ccda672ffd77ee23c4ee16969da1b85"; + sha256 = "1g2c6w44jmf0vlxc4592phw5a9z40xzrsg64x3wljqa9mxq40qdp"; + }; + + postInstall = '' + mkdir -p $out/share/cmake/modules + cp ${src}/cmake/modules/Find${pname}.cmake $out/share/cmake/modules + ''; + + nativeBuildInputs = [ + cmake + ]; +} diff --git a/pkgs/openhexagon/ssvstart.nix b/pkgs/openhexagon/ssvstart.nix new file mode 100644 index 0000000..eb2651e --- /dev/null +++ b/pkgs/openhexagon/ssvstart.nix @@ -0,0 +1,46 @@ +{ stdenv, fetchFromGitHub, + cmake, + ssvutils, + ssvjsoncpp, + ssvutilsjson, + sfml }: + +stdenv.mkDerivation rec { + pname = "SSVStart"; + version = "2013.06.14"; + + src = fetchFromGitHub { + owner = "SuperV1234"; + repo = pname; + rev = "40dcafc7ce35b05b3e72901201a92bfbc907a2f7"; + sha256 = "00g8hqsa5lh0hdj7949fpi41rcy7bsnximknj59r3w338msvqkqg"; + }; + + nativeBuildInputs = [ + cmake + ]; + + cmakeFlags = [ + "-DSSVJSONCPP_INCLUDE_DIR=${ssvjsoncpp}/include" + "-DSSVUTILS_INCLUDE_DIR=${ssvutils}/include" + ]; + + preConfigure = '' + rm -r ./extlibs/* + ln -s ${ssvjsoncpp}/share ./extlibs/SSVJsonCpp; + ln -s ${ssvutils}/share ./extlibs/SSVUtils; + ln -s ${ssvutilsjson}/share ./extlibs/SSVUtilsJson; + ''; + + postInstall = '' + mkdir -p $out/share/cmake/modules + cp ${src}/cmake/modules/Find${pname}.cmake $out/share/cmake/modules + ''; + + buildInputs = [ + ssvjsoncpp + ssvutils + ssvutilsjson + sfml + ]; +} diff --git a/pkgs/openhexagon/ssvutils.nix b/pkgs/openhexagon/ssvutils.nix new file mode 100644 index 0000000..389e699 --- /dev/null +++ b/pkgs/openhexagon/ssvutils.nix @@ -0,0 +1,22 @@ +{ stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + pname = "SSVUtils"; + version = "2013.06.14"; + + src = fetchFromGitHub { + owner = "SuperV1234"; + repo = pname; + rev = "20b2f63488e8fea717db2e5e8e5a919d617ae32a"; + sha256 = "1ai916x0g8d8x2q8hwgsb2r97h8xg3ym70g6xdwil8334wammcdv"; + }; + + postInstall = '' + mkdir -p $out/share/cmake/modules + cp ${src}/cmake/modules/FindSSVUtils.cmake $out/share/cmake/modules + ''; + + nativeBuildInputs = [ + cmake + ]; +} diff --git a/pkgs/openhexagon/ssvutilsjson.nix b/pkgs/openhexagon/ssvutilsjson.nix new file mode 100644 index 0000000..d93ec92 --- /dev/null +++ b/pkgs/openhexagon/ssvutilsjson.nix @@ -0,0 +1,38 @@ +{ stdenv, fetchFromGitHub, cmake, ssvutils, ssvjsoncpp }: + +stdenv.mkDerivation rec { + pname = "SSVUtilsJson"; + version = "2013.06.14"; + + src = fetchFromGitHub { + owner = "SuperV1234"; + repo = pname; + rev = "57c7c45eb4e2cf8b114a153d690fb111ea520ceb"; + sha256 = "10zn0alxk6g1zmm39l9mv8whamlljm1b6dckhlbwzl112falabgd"; + }; + + nativeBuildInputs = [ + cmake + ]; + + cmakeFlags = [ + "-DSSVJSONCPP_INCLUDE_DIR=${ssvjsoncpp}/include" + "-DSSVUTILS_INCLUDE_DIR=${ssvutils}/include" + ]; + + preConfigure = '' + rm -r ./extlibs/* + ln -s ${ssvjsoncpp}/share ./extlibs/SSVJsonCpp; + ln -s ${ssvutils}/share ./extlibs/SSVUtils; + ''; + + postInstall = '' + mkdir -p $out/share/cmake/modules + cp ${src}/cmake/modules/FindSSVUtilsJson.cmake $out/share/cmake/modules + ''; + + buildInputs = [ + ssvjsoncpp + ssvutils + ]; +}