-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
88 lines (78 loc) · 2.3 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
# Fix duplicate instances of these inputs by pointing them to my inputs
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, flake-utils, naersk, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [ (import rust-overlay) ];
# Read from `rust-toolchain.toml` instead of adding `rust-bin.nightly.latest.default` to devShell `buildInputs`
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naerskLib = pkgs.callPackage naersk {
cargo = rustToolchain;
rustc = rustToolchain;
};
pkgs = import nixpkgs {
inherit system overlays;
config = {
allowUnfree = true;
};
};
# These are mostly needed for raylib to build
packages = with pkgs; [
# [Raylib]
cmake
] ++ pkgs.lib.lists.optionals stdenv.isLinux [
# [Raylib]
clang
libclang
libcxx # C++ std library
libGL
xorg.libX11
xorg.libXrandr
xorg.libXinerama
xorg.libXcursor
xorg.libXi
xorg.libXi
libatomic_ops
mesa
alsa-lib
glibc
# [Wayland]
wayland
wayland-protocols
libxkbcommon
] ++ pkgs.lib.lists.optionals stdenv.isDarwin [
# [Raylib]
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/darwin/apple-sdk/frameworks.nix
darwin.apple_sdk.frameworks.Cocoa
darwin.apple_sdk.frameworks.Kernel
];
# Inputs needed at compile-time
nativeBuildInputs = with pkgs; [ rustToolchain ];
# Inputs needed at runtime
buildInputs = with pkgs; [ ] ++ packages;
in
{
packages.default = naerskLib.buildPackage {
src = ./.;
};
devShells = {
default = pkgs.mkShell {
inherit buildInputs;
nativeBuildInputs = nativeBuildInputs ++ [
pkgs.cargo-watch
];
};
};
});
}