-
Notifications
You must be signed in to change notification settings - Fork 15
/
default.nix
56 lines (44 loc) · 1.29 KB
/
default.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
let
rpath = with pkgs; pkgs.lib.makeLibraryPath [ vulkan-loader ];
# Tell Nix to ignore in-tree build artifact directory 'target' when
# determining the unique source fingerprint of the repo.
src = builtins.filterSource
(path: type: type != "directory" || builtins.baseNameOf path != "target")
./.;
pkgs = import <nixpkgs> {};
sources = import ./nix/sources.nix;
naersk = pkgs.callPackage sources.naersk {};
version = "0.1.0";
basename = "magog";
in naersk.buildPackage {
inherit src;
name = "${basename}-${version}";
buildInputs = with pkgs; [
# Needed by cargo dependencies.
cmake gcc zlib pkgconfig openssl
# wgpu graphics dependencies
vulkan-loader xorg.libXcursor xorg.libXi xorg.libXrandr
makeWrapper
];
# Optimize binary size.
prePatch = ''
cat >> Cargo.toml << EOF
[profile.release]
lto = true
codegen-units = 1
panic = 'abort'
EOF
'';
# Wrap with necessary runtime libraries
postInstall = ''
if [[ -f $out/bin/${basename} ]]; then
wrapProgram $out/bin/${basename} --prefix LD_LIBRARY_PATH : "${rpath}"
fi
'';
meta = with pkgs.lib; {
description = "A fantasy roguelike game";
homepage = https://github.com/rsaarelm/magog;
license = licenses.agpl3;
platforms = platforms.all;
};
}