forked from SuperTux/supertux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
137 lines (123 loc) · 4.8 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# SuperTux
# Copyright (C) 2021 Ingo Ruhnke <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
description = "A 2D platform game featuring Tux the penguin";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
tinycmmc.url = "github:grumbel/tinycmmc";
tinycmmc.inputs.nixpkgs.follows = "nixpkgs";
tinycmmc.inputs.flake-utils.follows = "flake-utils";
sexpcpp.url = "github:lispparser/sexp-cpp";
sexpcpp.inputs.nixpkgs.follows = "nixpkgs";
sexpcpp.inputs.flake-utils.follows = "flake-utils";
sexpcpp.inputs.tinycmmc.follows = "tinycmmc";
tinygettext.url = "github:tinygettext/tinygettext";
tinygettext.inputs.nixpkgs.follows = "nixpkgs";
tinygettext.inputs.flake-utils.follows = "flake-utils";
tinygettext.inputs.tinycmmc.follows = "tinycmmc";
SDL2_ttf.url = "github:SuperTux/SDL_ttf";
SDL2_ttf.inputs.nixpkgs.follows = "nixpkgs";
SDL2_ttf.inputs.flake-utils.follows = "flake-utils";
squirrel_src.url = "github:albertodemichelis/squirrel";
squirrel_src.flake = false;
};
outputs = { self, nixpkgs, flake-utils,
tinycmmc, sexpcpp, tinygettext, SDL2_ttf,
squirrel_src }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in rec {
packages = flake-utils.lib.flattenTree rec {
squirrel = pkgs.stdenv.mkDerivation {
pname = "squirrel";
version = "3.2";
src = squirrel_src;
nativeBuildInputs = [
pkgs.cmake
];
};
supertux2 = pkgs.stdenv.mkDerivation rec {
pname = "supertux2";
# FIXME: Should use `git describe` to get the version
# number or leave it to cmake, but the .git/ directory
# isn't included in the Nix store.
version = "0.6.3-${nixpkgs.lib.substring 0 8 self.lastModifiedDate}-${self.shortRev or "dirty"}";
src = nixpkgs.lib.cleanSource ./.;
patchPhase = let
ver = builtins.splitVersion version;
in ''
substituteInPlace config.h.cmake \
--replace "#define _SQ64" ""
cat > version.cmake <<EOF
SET(SUPERTUX_VERSION_MAJOR ${builtins.elemAt ver 0})
SET(SUPERTUX_VERSION_MINOR ${builtins.elemAt ver 1})
SET(SUPERTUX_VERSION_PATCH ${builtins.elemAt ver 2})
SET(SUPERTUX_VERSION_TWEAK ${builtins.elemAt ver 3})
SET(SUPERTUX_VERSION_STRING "v${version}")
SET(SUPERTUX_VERSION_BUILD "${builtins.elemAt ver 4}")
EOF
'';
cmakeFlags = [
"-DINSTALL_SUBDIR_BIN=bin"
"-DUSE_SYSTEM_SDL2_TTF=ON"
];
enableParallelBuilding = true;
nativeBuildInputs = [
pkgs.cmake
pkgs.pkgconfig
pkgs.makeWrapper
pkgs.git
];
postFixup = ''
wrapProgram $out/bin/supertux2 \
--prefix LIBGL_DRIVERS_PATH ":" "${pkgs.mesa.drivers}/lib/dri" \
--prefix LD_LIBRARY_PATH ":" "${pkgs.mesa.drivers}/lib"
'';
buildInputs = [
squirrel
sexpcpp.packages.${system}.default
tinygettext.packages.${system}.default
SDL2_ttf.packages.${system}.default
pkgs.physfs
pkgs.libpng
pkgs.curl
pkgs.fmt_8
pkgs.libGL
pkgs.libGLU
pkgs.glew
pkgs.gtest
pkgs.glm
pkgs.SDL2
pkgs.SDL2_image
pkgs.openal
pkgs.libvorbis
pkgs.libogg
pkgs.gtest
];
};
default = supertux2;
};
}
);
}