-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
94 lines (82 loc) · 2.49 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
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
utils = {
url = "github:numtide/flake-utils";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, utils, rust-overlay, crane }:
utils.lib.eachSystem ["aarch64-linux" "x86_64-linux"] (system:
let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs { inherit system overlays; };
craneLib = crane.mkLib pkgs;
# Build inputs
requiredPrograms = with pkgs; [
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
trunk
pkg-config
];
# Compiletime/Runtime deps (native linux build)
requiredLibsLinux = with pkgs; [
# misc. libraries
openssl
# GUI libs
libxkbcommon
libGL
fontconfig
# wayland libraries
wayland
# x11 libraries
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libX11
];
# IDE/shell dependencies
developPrograms = with pkgs; [
clippy
rust-analyzer-unwrapped
cargo-edit
];
# Autofetch project info from Cargo
cargoDesc = pkgs.lib.trivial.importTOML ./Cargo.toml;
projectName = cargoDesc.package.name;
projectVersion = cargoDesc.package.version;
packageDef = rec {
pname = projectName;
version = projectVersion;
src =
pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type: craneLib.filterCargoSources path type;
};
# https://github.com/NixOS/nix/issues/4623
# GIT_LFS_SKIP_SMUDGE = 1;
strictDeps = true;
nativeBuildInputs = requiredPrograms;
};
in
rec {
# `nix develop`
devShells.default = pkgs.mkShell rec {
nativeBuildInputs = developPrograms ++ requiredPrograms;
buildInputs = requiredLibsLinux;
shellHook = ''
RUST_LIBDIR=$(rustc --print target-libdir)
FLAKE_LIBDIR="${pkgs.lib.makeLibraryPath buildInputs}"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$FLAKE_LIBDIR:$RUST_LIBDIR:target/debug/deps"
'';
};
});
}