-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
68 lines (59 loc) · 2.19 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
blog.url =
"github:willmcpherson2/blog/73fcac8b8985372040ae4350474533a2087af728";
letscape.url =
"github:willmcpherson2/letscape/96102b8a3f941e6eb29de407df6b7679a15746ea";
jmusic.url =
"git+ssh://[email protected]/willmcpherson2/jmusic?rev=cfadaa2d4359d94b4ac0d651bcb3f8b15b5df267";
};
outputs = { self, nixpkgs, blog, letscape, jmusic }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
conf = pkgs.writeTextDir "nginx.conf" (builtins.readFile ./nginx.conf);
services = pkgs.symlinkJoin {
name = "services";
paths = [
conf
blog.packages.x86_64-linux.default
letscape.packages.x86_64-linux.default
jmusic.packages.x86_64-linux.default
];
};
in {
packages.x86_64-linux.default = pkgs.writeShellApplication {
name = "willmcpherson2.com";
runtimeInputs = [
pkgs.nginx
blog.packages.x86_64-linux.server
letscape.packages.x86_64-linux.node
jmusic.packages.x86_64-linux.jdk
];
text = ''
echo "starting services..."
kill -- "-$(cat services.pid)" || true
echo $PPID > services.pid
mkdir -p storage
storage=$(readlink -f storage)
rm -rf services
cp -r ${services} services
chmod -R +w services
services=$(readlink -f services)
cd "$services/static"
static-web-server -p 8001 -g info -d . >> "$storage/server.log" 2>&1 &
cd "$services/letscape"
PORT=8002 LETSCAPE_DB="$storage/letscape.json" npm start >> "$storage/letscape.log" 2>&1 &
cd "$services/jmusic"
java -Dnogui=true -jar JMusicBot.jar >> "$storage/jmusic.log" 2>&1 &
cd "$services"
mkdir -p /var/cache/nginx/
mkdir -p /var/log/nginx/
ln -s /var/log/nginx/access.log "$storage/nginx-access.log" || true
ln -s /var/log/nginx/error.log "$storage/nginx-error.log" || true
nginx -c "$services/nginx.conf" >> "$storage/nginx.log" 2>&1 &
echo "services started."
'';
};
};
}