-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
117 lines (106 loc) · 3.44 KB
/
flake.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
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
{
description = "yaaaaaaaaaaaaaaaaaaaaa";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
zig-overlay = {
url = "github:mitchellh/zig-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
zls = {
# - [mach needs zls fork :/](https://discord.com/channels/996677443681267802/996677444360736831/1283458075675590838)
url = "github:slimsag/zls/2024.5.0-mach";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.zig-overlay.follows = "zig-overlay";
};
zig2nix = {
url = "github:Cloudef/zig2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
mach-flake = {
url = "github:Cloudef/mach-flake";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.zig2nix.follows = "zig2nix";
};
};
outputs = inputs:
inputs.flake-utils.lib.eachDefaultSystem (system: let
flakePackage = flake: package: flake.packages."${system}"."${package}";
flakeDefaultPackage = flake: flakePackage flake "default";
# - [Zig version | Mach](https://machengine.org/docs/zig-version/)
# - [Nominated Zig versions](https://machengine.org/docs/nominated-zig/)
# - [zig-overlay/sources.json](https://github.com/mitchellh/zig-overlay/blob/main/sources.json)
# - [mach-flake templates flake.nix](https://github.com/Cloudef/mach-flake/blob/eca800e7fa289e95d3c0f32284763ad6984bb0a9/templates/engine/flake.nix)
mach-env = inputs.mach-flake.outputs.mach-env.${system} {};
overlays = [
(self: super: {
zig = mach-env.zig;
zls = (flakePackage inputs.zls "zls").overrideAttrs (old: {
nativeBuildInputs = [
mach-env.zig
];
buildInputs = [
mach-env.zig
];
});
})
];
pkgs = import inputs.nixpkgs {
inherit system;
inherit overlays;
};
fhs = pkgs.buildFHSEnv {
name = "fhs-shell";
targetPkgs = p: (env-packages p) ++ (custom-commands p);
runScript = "${pkgs.zsh}/bin/zsh";
profile = ''
export FHS=1
# source ./.venv/bin/activate
# source .env
'';
};
custom-commands = pkgs: [
(pkgs.writeShellScriptBin "todo" ''
#!/usr/bin/env bash
cd $PROJECT_ROOT
'')
];
env-packages = pkgs:
(with pkgs; [
pkg-config
zig
zls
gdb
curl
fswatch
imagemagick
glslang
shaderc
# - [nixOS usage | Mach: zig game engine & graphics toolkit](https://machengine.org/about/nixos-usage/)
xorg.libX11
vulkan-loader
])
++ [ ]
++ (custom-commands pkgs);
stdenv = pkgs.clangStdenv;
# stdenv = pkgs.gccStdenv;
in {
packages = {};
overlays = {};
devShells.default =
pkgs.mkShell.override {
inherit stdenv;
} {
nativeBuildInputs = (env-packages pkgs) ++ [fhs];
inputsFrom = [];
shellHook = ''
export PROJECT_ROOT="$(pwd)"
export LD_LIBRARY_PATH=${pkgs.xorg.libX11}/lib:${pkgs.vulkan-loader}/lib:$LD_LIBRARY_PATH
'';
};
});
}