-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshell.nix
More file actions
75 lines (63 loc) · 1.61 KB
/
shell.nix
File metadata and controls
75 lines (63 loc) · 1.61 KB
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
{pkgs ? import <nixpkgs> {}}: let
getLibFolder = pkg: "${pkg}/lib";
in
pkgs.stdenv.mkDerivation {
name = "bot";
nativeBuildInputs = with pkgs; [
# LLVM & GCC
gcc
cmake
gnumake
pkg-config
llvmPackages.llvm
llvmPackages.clang
# Hail the Nix
nixd
nixpkgs-fmt
nixpkgs-lint
# Launch scripts
just
# Rust
rustc
cargo
clippy
rustfmt
cargo-watch
rust-analyzer
];
buildInputs = with pkgs; [
openssl
];
# Set Environment Variables
RUST_BACKTRACE = 1;
NIX_LDFLAGS = "-L${(getLibFolder pkgs.libiconv)}";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.gcc
pkgs.libiconv
pkgs.llvmPackages.llvm
];
shellHook = ''
# Load the environment variables from the .env file
if [ ! -f .env ]; then
echo "Please enter your telegram bot token: ";
read -r TELOXIDE_TOKEN;
echo "TELOXIDE_TOKEN=$TELOXIDE_TOKEN" > .env;
else
source .env;
fi
# Set the environment variable
# export TELOXIDE_TOKEN=$TELOXIDE_TOKEN;
# Start watching for changes
# Start watching for changes in the background
# cargo watch -x "run --bin bot" &
# Store the PID of the background process
# CARGO_WATCH_PID=$!
# Function to clean up the background process on exit
# cleanup() {
# kill $CARGO_WATCH_PID
# }
# Trap EXIT signal to run cleanup function
# trap cleanup EXIT
'';
}