forked from OpenTabletDriver/TabletBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
58 lines (47 loc) · 1.44 KB
/
shell.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
# https://nixos.wiki/wiki/Rust#Installation_via_rustup
{ pkgs ? import <nixpkgs> {} }:
let
readFileIfExists = path: with pkgs.lib; if pathExists path then readFile path else null;
default = pkgs.callPackage ./. {};
rustDeps = with pkgs; [
llvmPackages_latest.llvm
llvmPackages_latest.bintools
zlib.out
rustup
xorriso
grub2
qemu
llvmPackages_latest.lld
python3
];
deps = default.nativeBuildInputs;
buildPath = toString ./.build/out;
build = pkgs.writers.writeBashBin "build" ''
cd ${toString ./src}
cargo build $@
'';
run = pkgs.writers.writeBashBin "run" ''
cd ${toString ./src}
cargo run $@
'';
utils = with pkgs; [
build # cargo build
run # cargo run
cachix
jq
];
in pkgs.mkShell rec {
RUSTC_VERSION = readFileIfExists ./rust-toolchain;
CARGO_HOME = toString ./.build/cargo;
CARGO_TARGET_DIR= toString ./.build/target;
RUSTUP_HOME = toString ./.build/rustup;
TABLETBOT_DATA = toString ./.build/data;
buildInputs = with pkgs; rustDeps ++ deps ++ utils;
shellHook = with pkgs.lib; ''
export LD_LIBRARY_PATH=${escapeShellArg (makeLibraryPath buildInputs)}
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
export PATH=$PATH:${escapeShellArg (makeBinPath buildInputs)}
[ -r ${TABLETBOT_DATA}/tokens ] && source ${TABLETBOT_DATA}/tokens
'';
}