···11-{ stdenv, fetchurl, lib, nixosTests }:
11+{ stdenv, fetchurl, lib, nixosTests, jq, moreutils }:
2233stdenv.mkDerivation rec {
44 pname = "wiki-js";
···88 url = "https://github.com/Requarks/wiki/releases/download/v${version}/${pname}.tar.gz";
99 sha256 = "sha256-O7KQ134zh9ullYyQZimmxfdRwXeHkD8aAhy/pRzIjxo=";
1010 };
1111+1212+ # Implements nodejs 18 support as it's not planned to fix this before
1313+ # the release of v3[1] which is planned to happen in 2023, but not before
1414+ # NixOS 23.05. However, in the lifespan of 23.05 v16 will get EOLed, so
1515+ # we have to hack this on our own.
1616+ #
1717+ # The problem we fix here is that `exports."/public/"` in a `package.json`
1818+ # is prohibited, i.e. you cannot export full directories anymore.
1919+ #
2020+ # Unfortunately it's non-trivial to fix this because v10 of `extract-files`
2121+ # (where the problem is fixed) doesn't work for graphql-tools (which depends
2222+ # on this). Updating this as well is also quite complex because in later
2323+ # versions the package was split up into multiple smaller packages and
2424+ # thus a lot of parts of the code-base would need to be changed accordingly.
2525+ #
2626+ # Since this is the only breaking change of nodejs 17/18[2][3], this workaround
2727+ # will be necessary until we can upgrade to v3.
2828+ #
2929+ # [1] https://github.com/requarks/wiki/discussions/6388
3030+ # [2] https://nodejs.org/en/blog/release/v17.0.0
3131+ # [3] https://nodejs.org/en/blog/release/v18.0.0
3232+ nativeBuildInputs = [ jq moreutils ];
3333+ postPatch = ''
3434+ # Dirty hack to implement nodejs-18 support.
3535+ <./node_modules/extract-files/package.json jq '
3636+ # error out loud if the structure has changed and we need to change
3737+ # this expression
3838+ if .exports|has("./public/")|not then
3939+ halt_error(1)
4040+ else
4141+ .exports."./public/*" = "./public/*.js" | del(.exports."./public/")
4242+ end
4343+ ' | sponge ./node_modules/extract-files/package.json
4444+ '';
11451246 sourceRoot = ".";
1347