Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thelounge: fix build #233511

Merged
merged 2 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions pkgs/applications/networking/irc/thelounge/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{ lib, stdenv, fetchFromGitHub, fetchYarnDeps, yarn, fixup_yarn_lock, nodejs, npmHooks, nixosTests }:

stdenv.mkDerivation (finalAttrs: {
pname = "thelounge";
version = "4.4.0";

src = fetchFromGitHub {
owner = "thelounge";
repo = "thelounge";
rev = "v${finalAttrs.version}";
hash = "sha256-2MHq71lKkFe1uHEENgUiYsO99bPyLmEZZIdcdgsZfSM=";
};

# 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-OKLsNGl94EDyLgP2X2tiwihgRQFXGvf5XgXwgX+JEpk=";
};

nativeBuildInputs = [ nodejs yarn fixup_yarn_lock npmHooks.npmInstallHook ];

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
winterqt marked this conversation as resolved.
Show resolved Hide resolved

runHook postConfigure
'';

buildPhase = ''
runHook preBuild

NODE_ENV=production yarn build
winterqt marked this conversation as resolved.
Show resolved Hide resolved

runHook postBuild
'';

# `npm prune` doesn't work and/or hangs for whatever reason.
preInstall = ''
rm -rf node_modules
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive --production
'';

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;
};
})
13 changes: 13 additions & 0 deletions pkgs/applications/networking/irc/thelounge/packages-path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/server/config.ts b/server/config.ts
index 543a8135..9744f00d 100644
--- a/server/config.ts
+++ b/server/config.ts
@@ -145,7 +145,7 @@ class Config {
}

getPackagesPath() {
- return path.join(this.#homePath, "packages");
+ return process.env.THELOUNGE_PACKAGES || path.join(this.#homePath, "packages");
}

getPackageModulePath(packageName: string) {
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ npmInstallHook() {
local -r nodeModulesPath="$packageOut/node_modules"

if [ ! -d "$nodeModulesPath" ]; then
npm prune --omit dev --no-save $npmInstallFlags "${npmInstallFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}"
if [ -z "${dontNpmPrune-}" ]; then
winterqt marked this conversation as resolved.
Show resolved Hide resolved
npm prune --omit dev --no-save $npmInstallFlags "${npmInstallFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}"
fi

find node_modules -maxdepth 1 -type d -empty -delete

cp -r node_modules "$nodeModulesPath"
Expand Down
1 change: 1 addition & 0 deletions pkgs/development/node-packages/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ mapAliases {
"@google/clasp" = pkgs.google-clasp; # Added 2023-05-07
"@nestjs/cli" = pkgs.nest-cli; # Added 2023-05-06
manta = pkgs.node-manta; # Added 2023-05-06
thelounge = pkgs.thelounge; # Added 2023-05-22
triton = pkgs.triton; # Added 2023-05-06
}
1 change: 0 additions & 1 deletion pkgs/development/node-packages/node-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@
, "textlint-rule-terminology"
, "textlint-rule-unexpanded-acronym"
, "textlint-rule-write-good"
, "thelounge"
, "thelounge-plugin-closepms"
, "thelounge-plugin-giphy"
, "thelounge-plugin-shortcuts"
Expand Down
10 changes: 0 additions & 10 deletions pkgs/development/node-packages/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -502,16 +502,6 @@ final: prev: {
'';
};

thelounge = prev.thelounge.override (oldAttrs: {
buildInputs = [ final.node-pre-gyp ];
postInstall = ''
echo /var/lib/thelounge > $out/lib/node_modules/thelounge/.thelounge_home
patch -d $out/lib/node_modules/thelounge -p1 < ${./thelounge-packages-path.patch}
'';
passthru.tests = { inherit (nixosTests) thelounge; };
meta = oldAttrs.meta // { maintainers = with lib.maintainers; [ winter ]; };
});

thelounge-plugin-closepms = prev.thelounge-plugin-closepms.override {
nativeBuildInputs = [ final.node-pre-gyp ];
};
Expand Down
15 changes: 0 additions & 15 deletions pkgs/development/node-packages/thelounge-packages-path.patch

This file was deleted.

2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12968,7 +12968,7 @@ with pkgs;

theharvester = callPackage ../tools/security/theharvester { };

inherit (nodePackages) thelounge;
thelounge = callPackage ../applications/networking/irc/thelounge { };

theLoungePlugins = with lib; let
pkgs = filterAttrs (name: _: hasPrefix "thelounge-" name) nodePackages;
Expand Down