-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflake.nix
101 lines (98 loc) · 3.78 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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
rust-overlay = { url = "github:oxalica/rust-overlay"; };
};
outputs = { self, nixpkgs, flake-utils, naersk, rust-overlay }:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages."${system}";
naersk-lib = naersk.lib."${system}";
buildInputs = with pkgs; (if pkgs.stdenv.isLinux then [
pkg-config
alsa-lib
libudev
xorg.libXcomposite
xorg.libXtst
xorg.libXrandr
xorg.libXext
xorg.libX11
xorg.libXfixes
xorg.xkeyboardconfig
xorg.libpciaccess
xorg.libxcb
xorg.libXdamage
xorg.libxshmfence
xorg.libXxf86vm
xorg.libXinerama
xorg.libXdamage
xorg.libXcursor
xorg.libXrender
xorg.libXScrnSaver
xorg.libXxf86vm
xorg.libXi
xorg.libSM
xorg.libICE
xorg.libXt
xorg.libXmu
xorg.libxcb
xorg.libXft
libGL
libva
pipewire.lib
libGLU
mesa.drivers
mesa.llvmPackages.llvm.lib
vulkan-loader
freeglut
libvdpau
] else []) ++ (if pkgs.stdenv.isDarwin then with pkgs.darwin.apple_sdk.frameworks; [
libiconv
Metal
CoreGraphics
CoreVideo
AppKit
] else []) ++ [
clang
lld
];
shellHook = if pkgs.stdenv.isLinux then ''export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath (with pkgs; [
alsa-lib
udev
vulkan-loader
])}"'' else "";
in
rec {
# `nix build`
packages.beeline = naersk-lib.buildPackage {
inherit buildInputs;
pname = "beeline";
root = ./.;
};
defaultPackage = packages.beeline;
# `nix run`
apps.beeline = flake-utils.lib.mkApp {
drv = packages.beeline;
};
defaultApp = apps.beeline;
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustc cargo rust-analyzer rustfmt ] ++ buildInputs;
inherit shellHook;
};
devShells.wasm = pkgs.mkShell {
nativeBuildInputs = let pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlay ]; }; in with pkgs; [
cargo
rust-analyzer
rustfmt
wasm-bindgen-cli
(rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
targets = [ "wasm32-unknown-unknown" ];
})
] ++ buildInputs;
inherit shellHook;
};
}
);
}