-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
76 lines (65 loc) · 2.18 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
inputsFrom = [(pkgs.callPackage ./default.nix {})];
buildInputs = with pkgs; [
rust-analyzer
rustfmt
crate2nix
clippy
(writeScriptBin "helpme" ''
__usage="
👋 Welcome to IMPHNEN CMS API development environment. 🚀
If you see this message, it means your are inside the Nix shell ❄️.
[Info]===============================================================>
Rustc Version: v${rustc.version}
Rustup Version: v${rustup.version}
Cargo Version: v${cargo.version}
Command available:
- start: start project in production 🛹 ( need to run build first )
- build: build project for production
- dev: start project in development
- start-docker: start project in docker container ( compose )
- build-docker: build project for docker container
- helpme: show this messages
Repository:
- https://github.com/IMPHNEN/imphnen-cms-api
[Info]===============================================================>
"
echo "$__usage"
'')
(writeScriptBin "dev" ''
cargo watch -x run
'')
(writeScriptBin "start" ''
echo "Starting project in production mode..."
echo "Najm Course API started on port $PORT 🛹..."
./result/bin/imphnen-cms-api
'')
(writeScriptBin "build" ''
echo "Building project..."
crate2nix generate
nix build -f Cargo.nix
echo "Now you can start the project with the command 'start'"
'')
(writeScriptBin "start-docker" ''
echo "Starting project in docker container..."
docker compose up -d
'')
(writeScriptBin "build-docker" ''
echo "Building project with docker..."
docker build -t imphnen-api:latest .
echo "Project built successfully."
echo "Now you can start the project with the command 'start-docker'"
'')
];
shellHook = ''
helpme
if [ -f .env ]; then
echo "Loading .env file..."
export $(cat .env | xargs)
echo "Successfully applied .env file."
else
echo ".env file not found."
fi
'';
}