nixpkgs/pkgs/servers/web-apps/wiki-js/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.3 KiB
Nix
Raw Normal View History

wiki-js: use nodejs18 Part of #229910. Unfortunately this is a little hacky because upstream doesn't intend to support it for 2.5, but only for 3.0 which isn't out yet, however nodejs-16 will get out of maintenance during the support-span of NixOS 23.05[1]. The only breaking change is that `extract-files` uses a deprecated way of exposing modules, I went through the list of other breaking changes in v17 and v18[2][3] and couldn't spot any usage of removed features, also local testing didn't reveal further issues. Unfortunately fixing that breakage turned out to be non-trivial. Currently, `extract-files@9.0.0` is used with the problematic portions in its `package.json`, however it's only a transitive dependency of `@graphql-tools/url-loader` & `apollo-upload-client`. Unfortunately, the versions of that in use require v9 and don't work with a newer version of `extract-files` with the problem fixed[4]. Also, upgrading the dependencies in question is not a feasible option because `graphql-tools` was split up into multiple smaller packages in v8 and also some of the APIs in use in `wiki.js` were dropped there[5], so this would also be very time-consuming and non-trivial to fix. Since this was the only issue, I decided to go down the hacky route and patch the problem in `package.json` of `extract-files` manually during our `patchPhase`. [1] https://github.com/requarks/wiki/discussions/6388 [2] https://nodejs.org/en/blog/release/v17.0.0 [3] https://nodejs.org/en/blog/release/v18.0.0 [4] Upon local testing, this broke with the following error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './public/extractFiles' is not defined by "exports" in /wiki/node_modules/extract-files/package.json [5] For instance `SchemaDirectiveVisitor` in `server/graph/directives/auth`.
2023-05-14 11:36:45 +00:00
{ stdenv, fetchurl, lib, nixosTests, jq, moreutils }:
2021-03-18 11:33:40 +00:00
stdenv.mkDerivation rec {
pname = "wiki-js";
2023-06-07 03:59:16 +00:00
version = "2.5.299";
2021-03-18 11:33:40 +00:00
src = fetchurl {
url = "https://github.com/Requarks/wiki/releases/download/v${version}/${pname}.tar.gz";
2023-06-07 03:59:16 +00:00
sha256 = "sha256-GYe05dbR8RwCzPedeCMUQTWZ51roM/V2jUPPv7o7UEU=";
2021-03-18 11:33:40 +00:00
};
wiki-js: use nodejs18 Part of #229910. Unfortunately this is a little hacky because upstream doesn't intend to support it for 2.5, but only for 3.0 which isn't out yet, however nodejs-16 will get out of maintenance during the support-span of NixOS 23.05[1]. The only breaking change is that `extract-files` uses a deprecated way of exposing modules, I went through the list of other breaking changes in v17 and v18[2][3] and couldn't spot any usage of removed features, also local testing didn't reveal further issues. Unfortunately fixing that breakage turned out to be non-trivial. Currently, `extract-files@9.0.0` is used with the problematic portions in its `package.json`, however it's only a transitive dependency of `@graphql-tools/url-loader` & `apollo-upload-client`. Unfortunately, the versions of that in use require v9 and don't work with a newer version of `extract-files` with the problem fixed[4]. Also, upgrading the dependencies in question is not a feasible option because `graphql-tools` was split up into multiple smaller packages in v8 and also some of the APIs in use in `wiki.js` were dropped there[5], so this would also be very time-consuming and non-trivial to fix. Since this was the only issue, I decided to go down the hacky route and patch the problem in `package.json` of `extract-files` manually during our `patchPhase`. [1] https://github.com/requarks/wiki/discussions/6388 [2] https://nodejs.org/en/blog/release/v17.0.0 [3] https://nodejs.org/en/blog/release/v18.0.0 [4] Upon local testing, this broke with the following error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './public/extractFiles' is not defined by "exports" in /wiki/node_modules/extract-files/package.json [5] For instance `SchemaDirectiveVisitor` in `server/graph/directives/auth`.
2023-05-14 11:36:45 +00:00
# Implements nodejs 18 support as it's not planned to fix this before
# the release of v3[1] which is planned to happen in 2023, but not before
# NixOS 23.05. However, in the lifespan of 23.05 v16 will get EOLed, so
# we have to hack this on our own.
#
# The problem we fix here is that `exports."/public/"` in a `package.json`
# is prohibited, i.e. you cannot export full directories anymore.
#
# Unfortunately it's non-trivial to fix this because v10 of `extract-files`
# (where the problem is fixed) doesn't work for graphql-tools (which depends
# on this). Updating this as well is also quite complex because in later
# versions the package was split up into multiple smaller packages and
# thus a lot of parts of the code-base would need to be changed accordingly.
#
# Since this is the only breaking change of nodejs 17/18[2][3], this workaround
# will be necessary until we can upgrade to v3.
#
# [1] https://github.com/requarks/wiki/discussions/6388
# [2] https://nodejs.org/en/blog/release/v17.0.0
# [3] https://nodejs.org/en/blog/release/v18.0.0
patches = [ ./drop-node-check.patch ];
wiki-js: use nodejs18 Part of #229910. Unfortunately this is a little hacky because upstream doesn't intend to support it for 2.5, but only for 3.0 which isn't out yet, however nodejs-16 will get out of maintenance during the support-span of NixOS 23.05[1]. The only breaking change is that `extract-files` uses a deprecated way of exposing modules, I went through the list of other breaking changes in v17 and v18[2][3] and couldn't spot any usage of removed features, also local testing didn't reveal further issues. Unfortunately fixing that breakage turned out to be non-trivial. Currently, `extract-files@9.0.0` is used with the problematic portions in its `package.json`, however it's only a transitive dependency of `@graphql-tools/url-loader` & `apollo-upload-client`. Unfortunately, the versions of that in use require v9 and don't work with a newer version of `extract-files` with the problem fixed[4]. Also, upgrading the dependencies in question is not a feasible option because `graphql-tools` was split up into multiple smaller packages in v8 and also some of the APIs in use in `wiki.js` were dropped there[5], so this would also be very time-consuming and non-trivial to fix. Since this was the only issue, I decided to go down the hacky route and patch the problem in `package.json` of `extract-files` manually during our `patchPhase`. [1] https://github.com/requarks/wiki/discussions/6388 [2] https://nodejs.org/en/blog/release/v17.0.0 [3] https://nodejs.org/en/blog/release/v18.0.0 [4] Upon local testing, this broke with the following error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './public/extractFiles' is not defined by "exports" in /wiki/node_modules/extract-files/package.json [5] For instance `SchemaDirectiveVisitor` in `server/graph/directives/auth`.
2023-05-14 11:36:45 +00:00
nativeBuildInputs = [ jq moreutils ];
postPatch = ''
# Dirty hack to implement nodejs-18 support.
<./node_modules/extract-files/package.json jq '
# error out loud if the structure has changed and we need to change
# this expression
if .exports|has("./public/")|not then
halt_error(1)
else
.exports."./public/*" = "./public/*.js" | del(.exports."./public/")
end
' | sponge ./node_modules/extract-files/package.json
'';
sourceRoot = ".";
dontBuild = true;
installPhase = ''
runHook preInstall
2021-03-18 11:33:40 +00:00
mkdir $out
cp -r . $out
runHook postInstall
2021-03-18 11:33:40 +00:00
'';
2022-04-08 16:44:02 +00:00
passthru = {
tests = { inherit (nixosTests) wiki-js; };
updateScript = ./update.sh;
};
2021-03-18 11:33:40 +00:00
meta = with lib; {
homepage = "https://js.wiki/";
description = "A modern and powerful wiki app built on Node.js";
license = licenses.agpl3Only;
maintainers = with maintainers; [ ma27 ];
};
}