Merge pull request #231841 from Ma27/wikijs-node18

wiki-js: use nodejs18

authored by

Jörg Thalheim and committed by
GitHub
fc8c839f 5fe2e6fb

+36 -2
+1 -1
nixos/modules/services/web-apps/wiki-js.nix
··· 133 133 WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}"; 134 134 DynamicUser = true; 135 135 PrivateTmp = true; 136 - ExecStart = "${pkgs.nodejs_16}/bin/node ${pkgs.wiki-js}/server"; 136 + ExecStart = "${pkgs.nodejs_18}/bin/node ${pkgs.wiki-js}/server"; 137 137 }; 138 138 }; 139 139 };
+35 -1
pkgs/servers/web-apps/wiki-js/default.nix
··· 1 - { stdenv, fetchurl, lib, nixosTests }: 1 + { stdenv, fetchurl, lib, nixosTests, jq, moreutils }: 2 2 3 3 stdenv.mkDerivation rec { 4 4 pname = "wiki-js"; ··· 8 8 url = "https://github.com/Requarks/wiki/releases/download/v${version}/${pname}.tar.gz"; 9 9 sha256 = "sha256-O7KQ134zh9ullYyQZimmxfdRwXeHkD8aAhy/pRzIjxo="; 10 10 }; 11 + 12 + # Implements nodejs 18 support as it's not planned to fix this before 13 + # the release of v3[1] which is planned to happen in 2023, but not before 14 + # NixOS 23.05. However, in the lifespan of 23.05 v16 will get EOLed, so 15 + # we have to hack this on our own. 16 + # 17 + # The problem we fix here is that `exports."/public/"` in a `package.json` 18 + # is prohibited, i.e. you cannot export full directories anymore. 19 + # 20 + # Unfortunately it's non-trivial to fix this because v10 of `extract-files` 21 + # (where the problem is fixed) doesn't work for graphql-tools (which depends 22 + # on this). Updating this as well is also quite complex because in later 23 + # versions the package was split up into multiple smaller packages and 24 + # thus a lot of parts of the code-base would need to be changed accordingly. 25 + # 26 + # Since this is the only breaking change of nodejs 17/18[2][3], this workaround 27 + # will be necessary until we can upgrade to v3. 28 + # 29 + # [1] https://github.com/requarks/wiki/discussions/6388 30 + # [2] https://nodejs.org/en/blog/release/v17.0.0 31 + # [3] https://nodejs.org/en/blog/release/v18.0.0 32 + nativeBuildInputs = [ jq moreutils ]; 33 + postPatch = '' 34 + # Dirty hack to implement nodejs-18 support. 35 + <./node_modules/extract-files/package.json jq ' 36 + # error out loud if the structure has changed and we need to change 37 + # this expression 38 + if .exports|has("./public/")|not then 39 + halt_error(1) 40 + else 41 + .exports."./public/*" = "./public/*.js" | del(.exports."./public/") 42 + end 43 + ' | sponge ./node_modules/extract-files/package.json 44 + ''; 11 45 12 46 sourceRoot = "."; 13 47