Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 97 lines 2.7 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 nix-update-script, 6 pnpm_9, 7 makeWrapper, 8 nodejs, 9}: 10 11let 12 pnpm = pnpm_9; 13in 14stdenv.mkDerivation (finalAttrs: { 15 pname = "etherpad-lite"; 16 version = "2.3.2"; 17 18 src = fetchFromGitHub { 19 owner = "ether"; 20 repo = "etherpad-lite"; 21 tag = "v${finalAttrs.version}"; 22 hash = "sha256-7PnqMLd6Mh/l3W1kjkb3aVeHrJXyIzU9/Xzm/VHBh38="; 23 }; 24 25 patches = [ 26 ./outdir.patch 27 # etherpad expects to read and write $out/lib/var/installed_plugins.json 28 # FIXME: this patch disables plugin support 29 ./dont-fail-on-plugins-json.patch 30 ]; 31 32 pnpmDeps = pnpm.fetchDeps { 33 inherit (finalAttrs) pname version src; 34 fetcherVersion = 1; 35 hash = "sha256-n7LolizpKng7zzccytYoCwJ7uGQbMagsgYPDuq0mdxU="; 36 }; 37 38 nativeBuildInputs = [ 39 pnpm.configHook 40 makeWrapper 41 ]; 42 43 buildInputs = [ 44 nodejs 45 ]; 46 47 buildPhase = '' 48 runHook preBuild 49 NODE_ENV="production" pnpm run build:etherpad 50 runHook postBuild 51 ''; 52 53 preInstall = '' 54 # remove unnecessary files 55 rm node_modules/.modules.yaml 56 pnpm prune --prod --ignore-scripts 57 find -type f \( -name "*.d.ts" -o -name "*.map" \) -exec rm -rf {} + 58 59 # remove non-deterministic files 60 rm node_modules/.modules.yaml 61 ''; 62 63 # Upstream scripts uses `pnpm run prod` which is equivalent to 64 # `cross-env NODE_ENV=production node --require tsx/cjs node/server.ts` 65 installPhase = '' 66 runHook preInstall 67 mkdir -p $out/{lib/etherpad-lite,bin} 68 cp -r node_modules ui src doc admin $out/lib/etherpad-lite 69 makeWrapper ${lib.getExe nodejs} $out/bin/etherpad-lite \ 70 --inherit-argv0 \ 71 --add-flags "--require tsx/cjs $out/lib/etherpad-lite/node_modules/ep_etherpad-lite/node/server.ts" \ 72 --suffix PATH : "${lib.makeBinPath [ pnpm ]}" \ 73 --set NODE_PATH "$out/lib/node_modules:$out/lib/etherpad-lite/node_modules/ep_etherpad-lite/node_modules" \ 74 --set-default NODE_ENV production 75 find $out/lib -xtype l -delete 76 runHook postInstall 77 ''; 78 79 passthru.updateScript = nix-update-script { }; 80 81 meta = { 82 description = "Modern really-real-time collaborative document editor"; 83 longDescription = '' 84 Etherpad is a real-time collaborative editor scalable to thousands of simultaneous real time users. 85 It provides full data export capabilities, and runs on your server, under your control. 86 ''; 87 homepage = "https://etherpad.org/"; 88 changelog = "https://github.com/ether/etherpad-lite/blob/${finalAttrs.src.rev}/CHANGELOG.md"; 89 maintainers = with lib.maintainers; [ 90 erdnaxe 91 f2k1de 92 ]; 93 license = lib.licenses.asl20; 94 mainProgram = "etherpad-lite"; 95 platforms = lib.platforms.unix; 96 }; 97})