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
|
{ lib
, stdenv
, fetchFromGitHub
, fetchYarnDeps
, nodejs
, yarn
, fixup_yarn_lock
, python3
, npmHooks
, darwin
, sqlite
, srcOnly
, buildPackages
, nixosTests
}:
stdenv.mkDerivation (finalAttrs: {
pname = "thelounge";
version = "4.4.1";
src = fetchFromGitHub {
owner = "thelounge";
repo = "thelounge";
rev = "v${finalAttrs.version}";
hash = "sha256-4FdNYP9VLgv/rfvT7KHCF+ABFsZvPbJjfz6IvvDkRNA=";
};
# Allow setting package path for the NixOS module.
patches = [ ./packages-path.patch ];
# Use the NixOS module's state directory by default.
postPatch = ''
echo /var/lib/thelounge > .thelounge_home
'';
offlineCache = fetchYarnDeps {
yarnLock = "${finalAttrs.src}/yarn.lock";
hash = "sha256-MM6SgVT7Pjdu96A4eWRucEzT7uNPxBqUDgHKl8mH2C0=";
};
nativeBuildInputs = [ nodejs yarn fixup_yarn_lock python3 npmHooks.npmInstallHook ] ++ lib.optional stdenv.isDarwin darwin.cctools;
buildInputs = [ sqlite ];
configurePhase = ''
runHook preConfigure
export HOME="$PWD"
fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache}
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
NODE_ENV=production yarn build
runHook postBuild
'';
# `npm prune` doesn't work and/or hangs for whatever reason.
preInstall = ''
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive --production
patchShebangs node_modules
# Build the sqlite3 package.
npm_config_nodedir="${srcOnly nodejs}" npm_config_node_gyp="${buildPackages.nodejs}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" npm rebuild --verbose --sqlite=${sqlite.dev}
# These files seemingly aren't needed, and also might not exist when the Darwin sandbox is disabled?
rm -rf node_modules/sqlite3/build-tmp-napi-v6/{Release/obj.target,node_sqlite3.target.mk}
'';
dontNpmPrune = true;
# Takes way, way, way too long.
dontStrip = true;
passthru.tests = nixosTests.thelounge;
meta = with lib; {
description = "Modern, responsive, cross-platform, self-hosted web IRC client";
homepage = "https://thelounge.chat";
changelog = "https://github.com/thelounge/thelounge/releases/tag/v${finalAttrs.version}";
maintainers = with maintainers; [ winter raitobezarius ];
license = licenses.mit;
inherit (nodejs.meta) platforms;
mainProgram = "thelounge";
};
})
|