-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
42 lines (31 loc) · 851 Bytes
/
Copy pathdefault.nix
File metadata and controls
42 lines (31 loc) · 851 Bytes
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
{ pkgs ? import <nixpkgs> { } }:
let manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
in
pkgs.rustPlatform.buildRustPackage rec {
pname = manifest.name;
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;
buildPhase = ''
mkdir -p $out/bin
cargo build --release --locked
cp target/release/${pname} $out/bin
'';
installPhase = ''
mkdir -p $out/lib/systemd/system
cat > $out/lib/systemd/system/${pname}.service <<'EOF'
[Unit]
Description=Pineapple Pastebin
After=network.target
[Service]
Type=notify
ExecStart=${placeholder "out"}/bin/${pname}
ExecReload=${pkgs.coreutils}/bin/kill -INT $MAINPID \
&& ${placeholder "out"}/bin/${pname}
ExecStop=${pkgs.coreutils}/bin/kill -9 $MAINPID
Restart=on-failure
[Install]
Wanted-By=multi-user.target
EOF
'';
}