-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
87 lines (74 loc) · 2.44 KB
/
flake.nix
File metadata and controls
87 lines (74 loc) · 2.44 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
{
description = "Zig 0.14 SDL3 Vulkan Voxel Engine";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
# Zig 0.14 is currently development/master.
# We use an overlay to get the latest compiler.
zig-overlay.url = "github:mitchellh/zig-overlay";
zig-overlay.inputs.nixpkgs.follows = "nixpkgs";
zig-overlay.inputs.flake-utils.follows = "flake-utils";
};
outputs = { self, nixpkgs, flake-utils, zig-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ zig-overlay.overlays.default ];
};
# Select Zig 0.14 (master/nightly)
zig = pkgs.zigpkgs.master;
in
{
packages.default = pkgs.stdenv.mkDerivation {
pname = "zigcraft";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [
zig
pkgs.pkg-config
pkgs.patchelf
pkgs.makeWrapper
];
buildInputs = [
pkgs.sdl3
pkgs.vulkan-loader
pkgs.vulkan-headers
pkgs.vulkan-validation-layers
];
# Disable hardening to fix "__builtin_va_arg_pack" error during C import
hardeningDisable = [ "all" ];
dontConfigure = true;
dontBuild = true;
installPhase = ''
export ZIG_GLOBAL_CACHE_DIR=$TMPDIR/zig-cache
zig build -Doptimize=Debug -Dtarget=x86_64-linux-gnu --prefix $out
'';
postFixup = ''
patchelf --add-rpath ${pkgs.lib.makeLibraryPath [ pkgs.sdl3 pkgs.vulkan-loader pkgs.stdenv.cc.cc.lib ]} $out/bin/zigcraft
wrapProgram $out/bin/zigcraft \
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib pkgs.vulkan-loader ]}
'';
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
zig
pkgs.zls
pkgs.pkg-config
pkgs.glslang
pkgs.weston
];
buildInputs = [
pkgs.sdl3
pkgs.vulkan-loader
pkgs.vulkan-headers
pkgs.vulkan-validation-layers
pkgs.mesa.drivers
];
shellHook = ''
echo "Zig 0.14 + SDL3 Dev Environment"
echo "Compiler: $(zig version)"
'';
};
});
}