forked from MatheoVignaud/tmc
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathflake.nix
More file actions
113 lines (98 loc) · 2.49 KB
/
Copy pathflake.nix
File metadata and controls
113 lines (98 loc) · 2.49 KB
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
{
description = "DevShell tmc";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
python = pkgs.python3.withPackages (ps: [
ps.pycparser
]);
commonInputs = with pkgs; [
xmake
cmake
ninja
pkg-config
git
curl
gnumake
gcc
python
sdl3
libpng
zlib
fmt
nlohmann_json
xorg.libX11
xorg.libXcursor
xorg.libXext
xorg.libXfixes
xorg.libXi
xorg.libXinerama
xorg.libXrandr
xorg.libXrender
xorg.libXScrnSaver
xorg.libXau
xorg.libXdmcp
xorg.libxcb
xorg.xorgproto
libxkbcommon
wayland
wayland-protocols
wayland-utils
];
armInputs = [
pkgs.pkgsCross.arm-embedded.stdenv.cc
];
runtimeLibPath = pkgs.lib.makeLibraryPath commonInputs;
launcher = pkgs.writeShellApplication {
name = "tmc-launch";
runtimeInputs = commonInputs;
text = ''
set -euo pipefail
root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
cd "$root"
if [ ! -f "$root/xmake.lua" ]; then
echo "Run this command from inside the tmc repository." >&2
exit 1
fi
if [ ! -f "$root/baserom.gba" ]; then
echo "Missing baserom.gba in the repository root." >&2
exit 1
fi
game_version="''${GAME_VERSION:-USA}"
case "$game_version" in
USA|EU) ;;
*)
echo "GAME_VERSION must be USA or EU for the PC port." >&2
exit 1
;;
esac
export XMAKE_ROOT=y
export XMAKE_USE_SYSTEM_SDL3=1
export LD_LIBRARY_PATH="${runtimeLibPath}''${LD_LIBRARY_PATH:+:''${LD_LIBRARY_PATH}}"
xmake f -y --game_version="$game_version"
xmake build_assets
xmake build -y
exec "$root/build/pc/tmc_pc" "$@"
'';
};
in {
devShells.${system}.default = pkgs.mkShell {
buildInputs = commonInputs ++ armInputs;
shellHook = ''
export XMAKE_ROOT=y
export XMAKE_USE_SYSTEM_SDL3=1
export LD_LIBRARY_PATH="${runtimeLibPath}''${LD_LIBRARY_PATH:+:''${LD_LIBRARY_PATH}}"
'';
};
packages.${system}.default = launcher;
apps.${system}.default = {
type = "app";
program = "${launcher}/bin/tmc-launch";
};
};
}