-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
85 lines (77 loc) · 2.34 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
naersk.url = "github:nix-community/naersk";
nixpkgs-mozilla = {
url = "github:mozilla/nixpkgs-mozilla";
flake = false;
} ;
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, naersk, flake-utils, nixpkgs-mozilla }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs) {
inherit system;
overlays = [(import nixpkgs-mozilla)];
};
toolchain = (pkgs.rustChannelOf {
date = "2023-02-20";
channel = "nightly";
sha256 = "sha256-x7w/OUVweXcofRLYKpDGubBngiOqQG5ZZPRfzpnTGf8=";
}).rust;
naersk' = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
};
LIBCLANG_PATH = "${pkgs.llvmPackages_14.libclang}/lib";
in {
packages.default = naersk'.buildPackage {
name = "werdol";
src = ./.;
nativeBuildInputs = with pkgs; [
cmake
pkg-config
vulkan-tools
];
buildInputs = with pkgs; [
alsa-lib
fontconfig
udev
wayland
wrapGAppsHook
xlibsWrapper
libxkbcommon
vulkan-loader
];
inherit LIBCLANG_PATH;
LD_LIBRARY_PATH="${pkgs.vulkan-loader}/lib";
# definitely *shouldn't* go in bin, but eh, whatever
postInstall = ''
cp -R assets $out/bin/
wrapProgram $out/bin/werdol --prefix 'LD_LIBRARY_PATH' ':' '${pkgs.vulkan-loader}/lib'
'';
# NB: will need some tweaks for MacOS
meta.broken = pkgs.stdenv.isDarwin;
passthru.exePath = "/bin/werdol";
};
devShell = with pkgs; mkShell {
inputsFrom = [self.packages."${system}".default];
nativeBuildInputs = [
clippy
rust-analyzer
rustfmt
];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
RUST_BACKTRACE = "1";
# HACK: wgpu winds up picking a strange assortment of paths to search
# when attempting to find a GPU driver. Give it a lil push.
LD_LIBRARY_PATH="${pkgs.vulkan-loader}/lib";
inherit LIBCLANG_PATH;
};
# Enables 'nix run'.
apps.default = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
};
}
);
}