diff --git a/home/default.nix b/home/default.nix index 9bdd2c0..1a8e2e0 100755 --- a/home/default.nix +++ b/home/default.nix @@ -157,7 +157,6 @@ mosh spotify-player gh - altserver-linux # development & tooling jdk21_headless diff --git a/packages/altserver/default.nix b/packages/altserver/default.nix index c0ba973..c09b792 100644 --- a/packages/altserver/default.nix +++ b/packages/altserver/default.nix @@ -1,55 +1,111 @@ { - stdenv, - fetchurl, lib, + clangStdenv, + fetchFromGitHub, + fetchgit, + requireFile, + cmake, + ninja, + pkg-config, + boost179, + openssl, + avahi, + zlib, + libuuid, + python3, + git, + libimobiledevice, + libplist, + libimobiledevice-glue, + libusbmuxd, + minizip, + websocketpp, + unzip, }: let - sources = { - x86_64-linux = { - arch = "x86_64"; - hash = "sha256-C+fDrcaewRd6FQMrO443xdDk/vtHycQ5zWLCOLPqF/s="; - }; - i686-linux = { - arch = "i586"; - hash = "sha256-xxucxefmFOiZn6fgAnKZ6yzxcG+mSpXvLzxlli493EI="; - }; - aarch64-linux = { - arch = "aarch64"; - hash = "sha256-iGAgqkS1DTgiUgUZZ9bsSsNfWggjSIem+Mluc6Xz3ik="; - }; - armv7l-linux = { - arch = "armv7"; - hash = "sha256-99olJlOMEMbZtFILpSRumZUj146IcyD3HrM5AimZPbg="; - }; + cpprestsdk = fetchFromGitHub { + owner = "microsoft"; + repo = "cpprestsdk"; + rev = "v2.10.18"; + sha256 = "sha256-RCt6BIFxRDTGiIjo5jhIxBeCOQsttWViQcib7M0wZ5Y="; + fetchSubmodules = true; }; - - source = sources.${stdenv.hostPlatform.system}; in - stdenv.mkDerivation (finalAttrs: { - pname = "altserver-linux"; - version = "0.0.5"; + clangStdenv.mkDerivation { + pname = "altserver"; + version = "unstable"; - src = fetchurl { - url = "https://github.com/NyaMisty/AltServer-Linux/releases/download/v${finalAttrs.version}/AltServer-${source.arch}"; - hash = source.hash; + src = fetchgit { + url = "https://github.com/sckova/AltServer-Linux"; + rev = "f9173b0805b64517a856fc133955753fde361c63"; + hash = "sha256-ts2YnGTdI5/Ze+7900Wvyxm2YJyQQ0qBlyLMRCAN20c="; + fetchSubmodules = true; + deepClone = true; }; - dontUnpack = true; + nativeBuildInputs = [ + cmake + ninja + pkg-config + git + unzip + ]; + + buildInputs = [ + boost179 + openssl + avahi + zlib + libuuid + python3 + libimobiledevice + libplist + libimobiledevice-glue + libusbmuxd + minizip + websocketpp + ]; + + NIX_CFLAGS_COMPILE = toString [ + "-D_GNU_SOURCE" + "-Wno-error=implicit-function-declaration" + "-Wno-error=incompatible-pointer-types" + "-Wno-error=int-conversion" + ]; + + cmakeFlags = [ + "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" + "-DCMAKE_C_FLAGS=-Wno-error=incompatible-pointer-types -Wno-implicit-function-declaration" + "-DCMAKE_CXX_FLAGS=-Wno-error=incompatible-pointer-types -Wno-implicit-function-declaration" + "-Wno-dev" + + "-D_XOPEN_SOURCE=700" + + "-DFETCHCONTENT_FULLY_DISCONNECTED=ON" + "-DFETCHCONTENT_SOURCE_DIR_CPPRESTSDK=${cpprestsdk}" + ]; + + postPatch = '' + # The build system tries to link a non-existent static library 'corecrypto_static'. + # We remove this dependency so it relies on the OpenSSL shims/libraries instead. + substituteInPlace cmake/CoreCrypto/CMakeLists.txt \ + --replace-fail "corecrypto_static" "" + ''; installPhase = '' runHook preInstall + mkdir -p $out/bin - cp $src $out/bin/alt-server - chmod u+x $out/bin/alt-server + # Copy the resulting binary (name may vary slightly by fork, finding executable) + find . -maxdepth 2 -type f -executable -name "AltServer" -exec cp {} $out/bin/ \; + runHook postInstall ''; - meta = { - homepage = "https://github.com/NyaMisty/AltServer-Linux"; - description = "AltServer for AltStore, but on-device. Requires root privileges as well as running a custom anisette server currently"; - license = lib.licenses.agpl3Only; - mainProgram = "alt-server"; - sourceProvenance = with lib.sourceTypes; [binaryNativeCode]; - platforms = ["x86_64-linux" "i686-linux" "aarch64-linux" "armv7l-linux"]; - maintainers = with lib.maintainers; [max-amb]; + meta = with lib; { + description = "AltServer for Linux (fork)"; + homepage = "https://github.com/sckova/AltServer-Linux"; + license = licenses.unfree; + platforms = platforms.linux; + maintainers = with maintainers; []; }; - }) + }