flake.nix 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # SuperTux - Milestone 1
  2. # Copyright (C) 2022 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. {
  23. description = "A 2D platform game featuring Tux the penguin";
  24. inputs = rec {
  25. nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
  26. tinycmmc.url = "github:grumbel/tinycmmc";
  27. tinycmmc.inputs.nixpkgs.follows = "nixpkgs";
  28. SDL-win32.url = "github:grumnix/SDL-win32";
  29. SDL-win32.inputs.nixpkgs.follows = "nixpkgs";
  30. SDL-win32.inputs.tinycmmc.follows = "tinycmmc";
  31. SDL_mixer-win32.url = "github:grumnix/SDL_mixer-win32";
  32. SDL_mixer-win32.inputs.nixpkgs.follows = "nixpkgs";
  33. SDL_mixer-win32.inputs.tinycmmc.follows = "tinycmmc";
  34. SDL_mixer-win32.inputs.SDL-win32.follows = "SDL-win32";
  35. SDL_image-win32.url = "github:grumnix/SDL_image-win32";
  36. SDL_image-win32.inputs.nixpkgs.follows = "nixpkgs";
  37. SDL_image-win32.inputs.tinycmmc.follows = "tinycmmc";
  38. SDL_image-win32.inputs.SDL-win32.follows = "SDL-win32";
  39. };
  40. outputs = { self, nixpkgs, tinycmmc, SDL-win32, SDL_mixer-win32, SDL_image-win32 }:
  41. tinycmmc.lib.eachSystemWithPkgs (pkgs:
  42. {
  43. packages = rec {
  44. default = supertux-milestone1;
  45. supertux-milestone1 = pkgs.stdenv.mkDerivation rec {
  46. pname = "supertux-milestone1";
  47. version = "0.1.4";
  48. src = nixpkgs.lib.cleanSource ./.;
  49. enableParallelBuilding = true;
  50. nativeBuildInputs = [
  51. pkgs.buildPackages.autoconf
  52. pkgs.buildPackages.automake
  53. pkgs.buildPackages.autoreconfHook
  54. pkgs.buildPackages.pkgconfig
  55. ]
  56. ++ (nixpkgs.lib.optional pkgs.targetPlatform.isLinux pkgs.makeWrapper);
  57. postFixup = ""
  58. + (nixpkgs.lib.optionalString pkgs.targetPlatform.isLinux ''
  59. wrapProgram $out/bin/supertux-milestone1 \
  60. --prefix LIBGL_DRIVERS_PATH ":" "${pkgs.mesa.drivers}/lib/dri" \
  61. --prefix LD_LIBRARY_PATH ":" "${pkgs.mesa.drivers}/lib"
  62. '')
  63. + (nixpkgs.lib.optionalString pkgs.stdenv.targetPlatform.isWindows ''
  64. mkdir -p $out/bin/
  65. find ${pkgs.windows.mcfgthreads} -iname "*.dll" -exec ln -sfv {} $out/bin/ \;
  66. find ${pkgs.stdenv.cc.cc} -iname "*.dll" -exec ln -sfv {} $out/bin/ \;
  67. ln -sfv ${SDL-win32.packages.${pkgs.system}.default}/bin/*.dll $out/bin/
  68. ln -sfv ${SDL_image-win32.packages.${pkgs.system}.default}/bin/*.dll $out/bin/
  69. ln -sfv ${SDL_mixer-win32.packages.${pkgs.system}.default}/bin/*.dll $out/bin/
  70. '');
  71. buildInputs =
  72. (if pkgs.stdenv.targetPlatform.isWindows
  73. then [
  74. SDL-win32.packages.${pkgs.system}.default
  75. SDL_image-win32.packages.${pkgs.system}.default
  76. SDL_mixer-win32.packages.${pkgs.system}.default
  77. ]
  78. else [
  79. pkgs.SDL
  80. pkgs.SDL_image
  81. pkgs.SDL_mixer
  82. pkgs.libGL
  83. pkgs.libGLU
  84. ]) ++
  85. [
  86. pkgs.zlib
  87. ];
  88. };
  89. supertux-milestone1-win32 = pkgs.runCommand "supertux-milestone1-win32" {} ''
  90. mkdir -p $out
  91. mkdir -p $out/data/
  92. cp -vr ${supertux-milestone1}/bin/supertux-milestone1.exe $out/
  93. cp -vLr ${supertux-milestone1}/bin/*.dll $out/
  94. cp -vr ${supertux-milestone1}/share/supertux-milestone1/. $out/data/
  95. '';
  96. supertux-milestone1-win32-zip = pkgs.runCommand "supertux-milestone1-win32-zip" {} ''
  97. mkdir -p $out
  98. WORKDIR=$(mktemp -d)
  99. cp --no-preserve mode,ownership --verbose --recursive \
  100. ${supertux-milestone1-win32}/. "$WORKDIR"
  101. cd "$WORKDIR"
  102. ${nixpkgs.legacyPackages.x86_64-linux.zip}/bin/zip \
  103. -r \
  104. $out/supertux-milestone1-${supertux-milestone1.version}-${pkgs.system}.zip \
  105. .
  106. '';
  107. };
  108. }
  109. );
  110. }