-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
118 lines (107 loc) · 3.33 KB
/
Copy pathflake.nix
File metadata and controls
118 lines (107 loc) · 3.33 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
{
description = "hyctl — Hytale game launcher CLI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
fenix,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
};
rustToolchain = pkgs.fenix.stable.withComponents [
"rustc"
"cargo"
"clippy"
"rustfmt"
"rust-analyzer"
"rust-src"
];
rustPlatform = pkgs.makeRustPlatform {
cargo = pkgs.fenix.stable.cargo;
rustc = pkgs.fenix.stable.rustc;
};
hyctl-unwrapped = rustPlatform.buildRustPackage {
pname = "hyctl";
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
# Strip the target/ dir from the source to avoid cache pollution.
# cargoLock handles reproducibility.
doCheck = false;
};
# Libraries the bundled SDL3 dlopen()s at runtime.
# On non-NixOS these come from standard system paths; on NixOS we
# provide them via buildFHSEnv so the game can find them.
gameLibs = pkgs: with pkgs; [
# Wayland
wayland
libdecor
libxkbcommon
# OpenGL / EGL / GLES
libGL
mesa
# X11 (SDL3 fallback backend)
libx11
libxcursor
libxext
libxfixes
libxi
libxrandr
libxscrnsaver
# System
dbus
systemd # provides libudev.so
liburing
];
# Wrapped binary: prepends Nix store lib paths to LD_LIBRARY_PATH so
# the bundled SDL3 can dlopen its backends (wayland, X11, GL, etc.).
# Simpler than a full FHS env — no bubblewrap needed.
hyctl = pkgs.symlinkJoin {
name = "hyctl";
paths = [ hyctl-unwrapped ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/hyctl \
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath (gameLibs pkgs)}
'';
};
in
{
packages = pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
default = hyctl;
unwrapped = hyctl-unwrapped;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ pkg-config gcc ];
buildInputs = with pkgs; [ openssl ] ++ gameLibs pkgs;
packages = [
rustToolchain
pkgs.cargo-edit
pkgs.cargo-audit
];
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
RUST_LOG = "hyctl=info";
# Let `cargo run -- run` find the bundled SDL3 backends at runtime.
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath (gameLibs pkgs)}:$LD_LIBRARY_PATH"
'';
};
}
);
}