Skip to content

Commit

Permalink
etherpad-lite: init at 2.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
erdnaxe committed Nov 5, 2024
1 parent d4a3fb6 commit f0cac03
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 0 deletions.
64 changes: 64 additions & 0 deletions pkgs/by-name/et/etherpad-lite/fix-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/src/node/hooks/express/specialpages.ts b/src/node/hooks/express/specialpages.ts
index 2e26eaa0c..0598ce161 100644
--- a/src/node/hooks/express/specialpages.ts
+++ b/src/node/hooks/express/specialpages.ts
@@ -89,7 +89,7 @@ const convertTypescript = (content: string) => {
const outputRaw = buildSync({
stdin: {
contents: content,
- resolveDir: path.join(settings.root, 'var','js'),
+ resolveDir: settings.tempVarJsDirectory,
loader: 'js'
},
alias:{
@@ -222,7 +222,7 @@ const convertTypescriptWatched = (content: string, cb: (output:string, hash: str
build({
stdin: {
contents: content,
- resolveDir: path.join(settings.root, 'var','js'),
+ resolveDir: settings.tempVarJsDirectory,
loader: 'js'
},
alias:{
@@ -278,7 +278,7 @@ exports.expressCreateServer = async (hookName: string, args: ArgsExpressType, cb



- const outdir = path.join(settings.root, 'var','js')
+ const outdir = settings.tempVarJsDirectory
// Create the outdir if it doesn't exist
if (!fs.existsSync(outdir)) {
fs.mkdirSync(outdir);
diff --git a/src/node/utils/Settings.ts b/src/node/utils/Settings.ts
index 4d7b421e1..12a5737bc 100644
--- a/src/node/utils/Settings.ts
+++ b/src/node/utils/Settings.ts
@@ -86,6 +86,9 @@ logger.info('All relative paths will be interpreted relative to the identified '
exports.settingsFilename = absolutePaths.makeAbsolute(argv.settings || 'settings.json');
exports.credentialsFilename = absolutePaths.makeAbsolute(argv.credentials || 'credentials.json');

+/* Temporary directory for built JS files */
+exports.tempVarJsDirectory = path.join(os.tmpdir(), 'js');
+
/**
* The app title, visible e.g. in the browser window
*/
diff --git a/src/static/js/pluginfw/installer.ts b/src/static/js/pluginfw/installer.ts
index c605378e1..27e3e487b 100644
--- a/src/static/js/pluginfw/installer.ts
+++ b/src/static/js/pluginfw/installer.ts
@@ -83,7 +83,13 @@ export const checkForMigration = async () => {
try {
await fs.access(installedPluginsPath, fs.constants.F_OK);
} catch (err) {
- await migratePluginsFromNodeModules();
+ logger.info(`${installedPluginsPath} not found, creating using current node modules`);
+ try {
+ await migratePluginsFromNodeModules();
+ } catch (err2) {
+ logger.warn(`unable to create ${installedPluginsPath}, skipping plugin migrations`);
+ return;
+ }
}

/*
77 changes: 77 additions & 0 deletions pkgs/by-name/et/etherpad-lite/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
lib,
stdenv,
fetchFromGitHub,
gitUpdater,
pnpm,
makeWrapper,
nodejs,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "etherpad-lite";
version = "2.2.6";

src = fetchFromGitHub {
owner = "ether";
repo = "etherpad-lite";
rev = "v${finalAttrs.version}";
hash = "sha256-B//EwfXS0BXxkksvB1EZZaZuPuruTZ3FySj9B5y0iBw=";
};

patches = [
# etherpad expects to read and write $out/lib/var/{installed_plugins.json,js}
./fix-paths.patch
];

pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-IdnlJmjgOMR04WwAEabepD4DWJyXii7XzS5v27Y1LHY=";
};

nativeBuildInputs = [
pnpm.configHook
makeWrapper
];

buildInputs = [
nodejs
];

buildPhase = ''
runHook preBuild
NODE_ENV="production" pnpm run build:etherpad
runHook postBuild
'';

# Upstream scripts uses `pnpm run prod` which is equivalent to
# `cross-env NODE_ENV=production node --require tsx/cjs node/server.ts`
installPhase = ''
runHook preInstall
mkdir -p $out/{lib,bin}
cp -r node_modules ui src doc admin $out/lib
makeWrapper ${lib.getExe nodejs} $out/bin/etherpad-lite \
--inherit-argv0 \
--add-flags "--require tsx/cjs $out/lib/node_modules/ep_etherpad-lite/node/server.ts" \
--suffix PATH : "${lib.makeBinPath [ pnpm ]}" \
--set NODE_PATH "$out/lib/node_modules:$out/lib/node_modules/ep_etherpad-lite/node_modules" \
--set-default NODE_ENV production
runHook postInstall
'';

passthru.updateScript = gitUpdater { };

meta = with lib; {
description = "A modern really-real-time collaborative document editor.";
longDescription = ''
Etherpad is a real-time collaborative editor scalable to thousands of simultaneous real time users.
It provides full data export capabilities, and runs on your server, under your control.
'';
homepage = "https://etherpad.org/";
changelog = "https://github.com/ether/etherpad-lite/blob/${finalAttrs.src.rev}/CHANGELOG.md";
maintainers = with maintainers; [ erdnaxe ];
license = licenses.asl20;
mainProgram = "etherpad-lite";
platforms = lib.platforms.unix;
};
})

0 comments on commit f0cac03

Please sign in to comment.