From 920be30f437f5687bbe7d34f201185f90c0721e9 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Fri, 17 Mar 2023 15:19:00 +0100 Subject: [PATCH] principia: init at unstable-2023-03-21 --- pkgs/games/principia/default.nix | 98 ++++++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 100 insertions(+) create mode 100644 pkgs/games/principia/default.nix diff --git a/pkgs/games/principia/default.nix b/pkgs/games/principia/default.nix new file mode 100644 index 000000000000..3cf98dada027 --- /dev/null +++ b/pkgs/games/principia/default.nix @@ -0,0 +1,98 @@ +{ lib +, stdenv +, fetchFromGitHub +, autoreconfHook +, pkg-config + +, curl +, freetype +, glew +, gtk2 +, libGL +, libjpeg +, libpng +, SDL2 +, SDL2_gfx +, SDL2_image +, SDL2_mixer +, SDL2_ttf +}: + +stdenv.mkDerivation { + pname = "principia"; + version = "unstable-2023-03-21"; + + src = fetchFromGitHub { + owner = "Bithack"; + repo = "principia"; + rev = "af2cfda21b6ce4c0725700e2a01b0597a97dbeff"; + hash = "sha256-jBWdXzbPpk23elHcs5sWkxXfkekj+aa24VvEHzid8KE="; + }; + + nativeBuildInputs = [ + autoreconfHook + pkg-config + ]; + + buildInputs = [ + curl + freetype + glew + gtk2 + libGL + libjpeg + libpng + SDL2 + SDL2_gfx + SDL2_image + SDL2_mixer + SDL2_ttf + ]; + + preAutoreconf = '' + cd build-linux + ''; + + # Since we bypass the "build-linux/go" wrapper script so we can use nixpkgs' + # autotools/make integration, set the release flags manually. + # https://github.com/Bithack/principia/issues/98 + preBuild = '' + RELEASE_SHARED="-ffast-math -DNDEBUG=1 -s -fomit-frame-pointer -fvisibility=hidden -fdata-sections -ffunction-sections" + makeFlagsArray+=( + CFLAGS="$RELEASE_SHARED -O1" + CXXFLAGS="$RELEASE_SHARED -O2 -fvisibility-inlines-hidden -fno-rtti" + LDFLAGS="-Wl,-O,-s,--gc-sections" + ) + ''; + + # `make install` only installs the binary, and the binary looks for data + # files in its same directory, so we override installPhase, install the + # binary in $out/share, and link to it from $out/bin + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + mkdir -p $out/share/principia + install -Dm755 principia $out/share/principia/principia + ln -s $out/share/principia/principia $out/bin/principia + + cp -r --dereference data-pc data-shared $out/share/principia/ + install -Dm644 principia.desktop $out/share/applications/principia.desktop + install -Dm644 principia-url-handler.desktop $out/share/applications/principia-url-handler.desktop + install -Dm644 principia.png $out/share/pixmaps/principia.png + + runHook postInstall + ''; + + # The actual binary is here, see comment above installPhase + stripDebugList = [ "share/principia" ]; + + meta = with lib; { + description = "Physics-based sandbox game"; + homepage = "https://principia-web.se/"; + downloadPage = "https://principia-web.se/download"; + license = licenses.bsd3; + maintainers = [ maintainers.fgaz ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 765682bcc040..d4d0638dcd4d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -35810,6 +35810,8 @@ with pkgs; planetary_annihilation = callPackage ../games/planetaryannihilation { }; + principia = callPackage ../games/principia { }; + prismlauncher-qt5 = libsForQt5.callPackage ../games/prismlauncher { }; prismlauncher = qt6Packages.callPackage ../games/prismlauncher { };