flake.nix 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # SuperTux
  2. # Copyright (C) 2021 Ingo Ruhnke <grumbel@gmail.com>
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining
  5. # a copy of this software and associated documentation files (the
  6. # "Software"), to deal in the Software without restriction, including
  7. # without limitation the rights to use, copy, modify, merge, publish,
  8. # distribute, sublicense, and/or sell copies of the Software, and to
  9. # permit persons to whom the Software is furnished to do so, subject to
  10. # the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be
  13. # included in all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. # Due to the use of submodules this has to be build with:
  23. #
  24. # nix build "git+file://$(pwd)?submodules=1"
  25. #
  26. # See: https://github.com/NixOS/nix/pull/5434
  27. {
  28. description = "A 2D platform game featuring Tux the penguin";
  29. inputs = rec {
  30. nixpkgs.url = "github:nixos/nixpkgs";
  31. nix.inputs.nixpkgs.follows = "nixpkgs";
  32. flake-utils.url = "github:numtide/flake-utils";
  33. };
  34. outputs = { self, nix, nixpkgs, flake-utils }:
  35. flake-utils.lib.eachDefaultSystem (system:
  36. let
  37. pkgs = nixpkgs.legacyPackages.${system};
  38. in rec {
  39. packages = flake-utils.lib.flattenTree rec {
  40. raqm = pkgs.stdenv.mkDerivation rec {
  41. pname = "libraqm";
  42. version = "0.7.2";
  43. src = fetchTarball {
  44. url = "https://github.com/HOST-Oman/libraqm/releases/download/v${version}/raqm-${version}.tar.xz";
  45. sha256 = "1shcs5l27l7380dvacvhl8wrdq3lix0wnhzvfdh7vx2pkzjs3zk6";
  46. };
  47. nativeBuildInputs = [
  48. pkgs.meson
  49. pkgs.cmake
  50. pkgs.ninja
  51. pkgs.gcc
  52. pkgs.pkgconfig
  53. pkgs.python3
  54. ];
  55. buildInputs = [
  56. pkgs.freetype
  57. pkgs.harfbuzz
  58. pkgs.fribidi
  59. ];
  60. propagatedBuildInputs = [
  61. pkgs.glib
  62. pkgs.pcre
  63. ];
  64. };
  65. supertux2 = pkgs.stdenv.mkDerivation rec {
  66. pname = "supertux2";
  67. # FIXME: Should use `git describe` to get the version
  68. # number or leave it to cmake, but the .git/ directory
  69. # isn't included in the Nix store.
  70. version = "0.6.2-unknown-" + (if (self ? shortRev) then self.shortRev else "dirty");
  71. src = nixpkgs.lib.cleanSource ./.;
  72. postPatch = let
  73. ver = builtins.splitVersion version;
  74. in ''cat > version.cmake <<EOF
  75. SET(SUPERTUX_VERSION_MAJOR ${builtins.elemAt ver 0})
  76. SET(SUPERTUX_VERSION_MINOR ${builtins.elemAt ver 1})
  77. SET(SUPERTUX_VERSION_PATCH ${builtins.elemAt ver 2})
  78. SET(SUPERTUX_VERSION_TWEAK )
  79. SET(SUPERTUX_VERSION_STRING "v${version}")
  80. SET(SUPERTUX_VERSION_BUILD "${builtins.elemAt ver 4}")
  81. EOF
  82. '';
  83. cmakeFlags = [ "-DINSTALL_SUBDIR_BIN=bin" ];
  84. enableParallelBuilding = true;
  85. nativeBuildInputs = [
  86. pkgs.cmake
  87. pkgs.ninja
  88. pkgs.gcc
  89. pkgs.pkgconfig
  90. pkgs.makeWrapper
  91. pkgs.git
  92. ];
  93. postFixup = ''
  94. wrapProgram $out/bin/supertux2 \
  95. --prefix LIBGL_DRIVERS_PATH ":" "${pkgs.mesa.drivers}/lib/dri" \
  96. --prefix LD_LIBRARY_PATH ":" "${pkgs.mesa.drivers}/lib"
  97. '';
  98. buildInputs = [
  99. raqm
  100. pkgs.boost
  101. pkgs.curl
  102. pkgs.fribidi
  103. pkgs.harfbuzz
  104. pkgs.freetype
  105. pkgs.libGL
  106. pkgs.libGLU
  107. pkgs.glew
  108. pkgs.gtest
  109. pkgs.glm
  110. pkgs.SDL2
  111. pkgs.SDL2_image
  112. pkgs.openal
  113. pkgs.libvorbis
  114. pkgs.libogg
  115. pkgs.gtest
  116. ];
  117. };
  118. };
  119. defaultPackage = packages.supertux2;
  120. }
  121. );
  122. }