This repository was archived by the owner on Nov 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.nix
More file actions
executable file
·79 lines (67 loc) · 1.77 KB
/
shell.nix
File metadata and controls
executable file
·79 lines (67 loc) · 1.77 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
76
77
78
79
{ pkgs ? import <nixpkgs> {}}:
let
# Create custom scripts as derivations
startScript = pkgs.writeScriptBin "pstart" ''
#!/bin/sh
# Store PID file in the TMP directory
PID_FILE="$TMP/edwood-pstart.pid"
# Check if process is already running
if [ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") 2>/dev/null; then
echo "Process already running with PID $(cat "$PID_FILE")"
exit 1
fi
# Start the process and store its PID
${pkgs.cargo}/bin/cargo run &
PID=$!
echo $PID > "$PID_FILE"
echo "Process started with PID $PID"
# Wait for the process to complete
wait $PID
rm -f "$PID_FILE"
'';
stopScript = pkgs.writeScriptBin "pstop" ''
#!/bin/sh
PID_FILE="$TMP/edwood-pstart.pid"
# Check if PID file exists
if [ ! -f "$PID_FILE" ]; then
echo "No process found. Is it running?"
exit 1
fi
PID=$(cat "$PID_FILE")
# Check if process is still running
if kill -0 $PID 2>/dev/null; then
echo "Stopping process with PID $PID"
kill $PID
rm -f "$PID_FILE"
else
echo "Process is not running, cleaning up PID file"
rm -f "$PID_FILE"
fi
'';
in
pkgs.mkShell {
buildInputs = with pkgs; [
rustc
cargo
rustfmt
rust-analyzer
clippy
ffmpeg
# edwood
edwood
startScript
stopScript
];
RUST_BACKTRACE = 1;
shellHook = ''
function to_webp() {
input_file="$1"
output_file="''${input_file%.*}.webp"
if [[ "''$input_file" == *.gif ]]; then
ffmpeg -i "''$input_file" -pix_fmt bgra -c:v libwebp_anim -lossless 1 -loop 0 -compression_level 6 "''$output_file"
else
ffmpeg -i "''$input_file" -pix_fmt bgra -c:v libwebp -lossless 1 -compression_level 6 "''$output_file"
fi
}
'';
}