From 96f0c2c191c50aae55715c0e7cbc93510354fcf4 Mon Sep 17 00:00:00 2001 From: Izorkin Date: Tue, 16 Feb 2021 10:09:14 +0300 Subject: [PATCH] mastodon, nixos/mastodon: use the same nodejs package in package and module --- nixos/modules/services/web-apps/mastodon.nix | 2 +- pkgs/servers/mastodon/default.nix | 12 ++++++++++-- pkgs/top-level/all-packages.nix | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/web-apps/mastodon.nix b/nixos/modules/services/web-apps/mastodon.nix index 37e5f7719b7b..24aea356de4e 100644 --- a/nixos/modules/services/web-apps/mastodon.nix +++ b/nixos/modules/services/web-apps/mastodon.nix @@ -450,7 +450,7 @@ in { else { PORT = toString(cfg.streamingPort); } ); serviceConfig = { - ExecStart = "${pkgs.nodejs-slim}/bin/node streaming"; + ExecStart = "${cfg.package}/run-streaming.sh"; Restart = "always"; RestartSec = 20; EnvironmentFile = "/var/lib/mastodon/.secrets_env"; diff --git a/pkgs/servers/mastodon/default.nix b/pkgs/servers/mastodon/default.nix index 8508fbe8f78b..b8582f68ebc5 100644 --- a/pkgs/servers/mastodon/default.nix +++ b/pkgs/servers/mastodon/default.nix @@ -1,5 +1,5 @@ { lib, stdenv, nodejs-slim, mkYarnPackage, fetchFromGitHub, bundlerEnv -, yarn, callPackage, imagemagick, ffmpeg, file, ruby_2_7 +, yarn, callPackage, imagemagick, ffmpeg, file, ruby_2_7, writeShellScript # Allow building a fork or custom version of Mastodon: , pname ? "mastodon" @@ -96,10 +96,18 @@ stdenv.mkDerivation rec { ln -s /var/log/mastodon log ln -s /tmp tmp ''; + propagatedBuildInputs = [ imagemagick ffmpeg file mastodon-gems.wrappedRuby ]; - installPhase = '' + + installPhase = let + run-streaming = writeShellScript "run-streaming.sh" '' + # NixOS helper script to consistently use the same NodeJS version the package was built with. + ${nodejs-slim}/bin/node ./streaming + ''; + in '' mkdir -p $out cp -r * $out/ + ln -s ${run-streaming} $out/run-streaming.sh ''; meta = with lib; { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d70c6f9bda07..85d4ff856394 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17921,7 +17921,11 @@ in mailman-web = with python3.pkgs; toPythonApplication mailman-web; - mastodon = callPackage ../servers/mastodon { }; + mastodon = callPackage ../servers/mastodon { + # With nodejs v14 the streaming endpoint breaks. Need migrate to uWebSockets.js or similar. + # https://github.com/tootsuite/mastodon/issues/15184 + nodejs-slim = nodejs-slim-12_x; + }; mattermost = callPackage ../servers/mattermost { }; matterircd = callPackage ../servers/mattermost/matterircd.nix { };