Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
211 lines (186 loc) · 6.48 KB
/
Copy pathflake.nix
File metadata and controls
211 lines (186 loc) · 6.48 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
{
description = "Horizon: Minecraft Java Edition 26.3 rewritten in Rust";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
linuxSystems = [ "x86_64-linux" "aarch64-linux" ];
systems = linuxSystems ++ [ "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
forLinuxSystems = f: nixpkgs.lib.genAttrs linuxSystems (system: f nixpkgs.legacyPackages.${system});
# The game's packages, built from this workspace (nix/, docs/nix.md). Releases are tagged by
# release.yml, which never uses this flake, so a build from it says which commit it is.
version = "0-unstable-${builtins.substring 0 8 (self.lastModifiedDate or "19700101")}";
gamePackages = pkgs:
let
call = pkgs.lib.callPackageWith (pkgs // packages // { inherit version; });
packages = {
horizon-engine = call ./nix/horizon-engine.nix { };
horizon-server = call ./nix/horizon-server.nix { };
horizon-prepare = call ./nix/horizon-prepare.nix { };
horizon-client = call ./nix/horizon-client.nix { };
};
in packages;
in {
packages = forAllSystems (pkgs: gamePackages pkgs // nixpkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux (
let
version = "0.2.0";
pname = "horizon-launcher";
unwrapped = pkgs.rustPlatform.buildRustPackage {
pname = "${pname}-unwrapped";
inherit version;
src = self;
cargoRoot = "launcher";
buildAndTestSubdir = "launcher";
cargoLock = {
lockFile = ./launcher/Cargo.lock;
};
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
libxkbcommon
wayland
libx11
libxcb
fontconfig
vulkan-loader
alsa-lib
];
doCheck = false;
};
desktopItem = pkgs.makeDesktopItem {
name = pname;
desktopName = "Horizon";
genericName = "Game launcher";
comment = "Install, prepare and play Horizon, Minecraft: Java Edition rewritten in Rust";
exec = pname;
icon = "horizon";
categories = [ "Game" ];
startupWMClass = "horizon-launcher";
};
horizonLauncher = pkgs.buildFHSEnv {
inherit pname version;
targetPkgs = pkgs: with pkgs; [
# Windowing, graphics, Vulkan, Wayland, X11
vulkan-loader
libglvnd
wayland
libxkbcommon
libx11
libxcb
libxcursor
libxext
libxi
libxrandr
libxrender
libxxf86vm
# Audio, udev & dev packages for native builds
udev
udev.dev
alsa-lib
alsa-lib.dev
# Desktop integration, fonts, keyring
fontconfig
freetype
dbus
xdg-utils
procps
# Mojang Java runtime dependencies
zlib
libxtst
# Gamemode support
gamemode
# Build environment for native mods
gcc
glibc.dev
pkg-config
];
runScript = "${unwrapped}/bin/horizon-launcher";
profile = ''
export HORIZON_LAUNCHER_NO_SELF_UPDATE=1
export HORIZON_LAUNCHER_DESKTOP_EXEC="''${HORIZON_LAUNCHER_DESKTOP_EXEC:-${pname}}"
export PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:''${PKG_CONFIG_PATH:-}"
'';
extraInstallCommands = ''
install -Dm444 ${desktopItem}/share/applications/${pname}.desktop -t $out/share/applications
if [ -d ${./packaging/icons/hicolor} ]; then
mkdir -p $out/share/icons/hicolor
cp -r ${./packaging/icons/hicolor}/. $out/share/icons/hicolor/
fi
'';
passthru = { inherit unwrapped; };
meta = with pkgs.lib; {
description = "Launcher for Horizon, Minecraft: Java Edition rewritten in Rust";
homepage = "https://playhorizon.dev";
license = licenses.mit;
platforms = [ "x86_64-linux" "aarch64-linux" ];
mainProgram = pname;
};
};
in {
horizon-launcher = horizonLauncher;
default = horizonLauncher;
})
);
overlays.default = final: prev: {
horizon-launcher = self.packages.${final.stdenv.hostPlatform.system}.horizon-launcher;
} // gamePackages final;
# services.horizon-server (docs/nix.md).
nixosModules = {
horizon-server = import ./nix/module.nix { inherit self; };
default = self.nixosModules.horizon-server;
};
checks = forAllSystems (pkgs: {
inherit (self.packages.${pkgs.stdenv.hostPlatform.system}) horizon-server horizon-prepare;
} // nixpkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
# The module in a VM, without any of Mojang's files.
nixos-module = pkgs.testers.runNixOSTest (import ./nix/tests/server.nix { inherit self; });
});
devShells = forLinuxSystems (pkgs: {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
coreutils
findutils
gnused
gnugrep
pkg-config
rustc
cargo
clang
mold
python3
];
buildInputs = with pkgs; [
libxkbcommon
wayland
vulkan-loader
fontconfig
freetype
alsa-lib
openssl
udev
libx11
libxcursor
libxrandr
libxi
];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; [
libxkbcommon
wayland
vulkan-loader
fontconfig
freetype
alsa-lib
udev
libx11
libxcursor
libxrandr
libxi
]);
};
});
};
}