-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.nix
95 lines (78 loc) · 2.06 KB
/
default.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
runCommand,
fetchFromGitHub,
napalm,
nodejs,
python3,
unstableGitUpdater,
}:
let
stopNpmCallingHome = ''
# Do not try to find npm in napalm-registry –
# it is not there and checking will slow down the build.
npm config set update-notifier false
# Same for security auditing, it does not make sense in the sandbox.
npm config set audit false
'';
src = fetchFromGitHub {
owner = "jtojnar";
repo = "pengu";
rev = "ad24f1faa1b2501ec097fd134d3769f214b40466";
sha256 = "sha256-TDUCnl6bK6Mnp/5oQx/c59LjSXOTRVCrbqzxILVEytU=";
};
in
napalm.buildPackage src rec {
pname = "pengu";
version = "unstable-2022-05-20";
customPatchPackages = {
# Patch shebangs.
"node-gyp-build" = pkgs: prev: {
};
};
nativeBuildInputs = [
# For node-gyp
python3
];
inherit nodejs;
npmCommands = [
# Let’s install again, this time running scripts.
"npm install --loglevel verbose --nodedir=${nodejs}/include/node"
# Patch shebangs so that scripts can run.
# napalm’s patching is not “overzealous” enough
# to fix the file linked by “node_modules/.bin/parcel”.
"patchShebangs node_modules/parcel/lib/bin.js"
# Build the front-end.
"npm run build"
# Clean up node_modules for production.
"npm install --only=production --loglevel verbose"
];
postConfigure = ''
# configurePhase sets $HOME
${stopNpmCallingHome}
'';
installPhase = ''
runHook preInstall
mkdir -p "$out"
cp -r * "$out"
mkdir -p "$out/lib/systemd/system"
echo > "$out/lib/systemd/system/pengu.service" "
[Unit]
After=network.target
After=postgresql.service
Description=Pengu virtual chat
[Service]
ExecStart=${nodejs}/bin/node $out/src
Restart=always
RestartSec=10
WorkingDirectory=$out
"
runHook postInstall
'';
passthru = {
inherit src;
updateScript = unstableGitUpdater {
# The updater tries src.url by default, which does not exist for fetchFromGitHub (fetchurl).
url = "${src.meta.homepage}.git";
};
};
}