update mastodon
This commit is contained in:
parent
0d75bf8f84
commit
ac4b913fdd
6 changed files with 1483 additions and 1442 deletions
|
@ -1,39 +1,27 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, nodejs-slim
|
||||
, bundlerEnv
|
||||
, nixosTests
|
||||
, yarn
|
||||
, callPackage
|
||||
, imagemagick
|
||||
, ffmpeg
|
||||
, file
|
||||
, ruby_3_0
|
||||
, writeShellScript
|
||||
, fetchYarnDeps
|
||||
, fixup_yarn_lock
|
||||
{ lib, stdenv, nodejs-slim, bundlerEnv, nixosTests
|
||||
, yarn, callPackage, imagemagick, ffmpeg, file, ruby, writeShellScript
|
||||
, fetchYarnDeps, prefetch-yarn-deps
|
||||
, brotli
|
||||
|
||||
# Allow building a fork or custom version of Mastodon:
|
||||
, pname ? "mastodon"
|
||||
, version ? import ./version.nix
|
||||
, srcOverride ? null
|
||||
, dependenciesDir ? ./. # Should contain gemset.nix, yarn.nix and package.json.
|
||||
, version ? srcOverride.version
|
||||
, patches ? []
|
||||
# src is a package
|
||||
, srcOverride ? callPackage ./source.nix { inherit patches; }
|
||||
, gemset ? ./. + "/gemset.nix"
|
||||
, yarnHash ? srcOverride.yarnHash
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
inherit pname version;
|
||||
|
||||
# Using overrideAttrs on src does not build the gems and modules with the overridden src.
|
||||
# Putting the callPackage up in the arguments list also does not work.
|
||||
src =
|
||||
if srcOverride != null then srcOverride else callPackage ./source.nix { };
|
||||
src = srcOverride;
|
||||
|
||||
mastodon-gems = bundlerEnv {
|
||||
mastodonGems = bundlerEnv {
|
||||
name = "${pname}-gems-${version}";
|
||||
inherit version;
|
||||
ruby = ruby_3_0;
|
||||
inherit version gemset ruby;
|
||||
gemdir = src;
|
||||
gemset = dependenciesDir + "/gemset.nix";
|
||||
# This fix (copied from https://github.com/NixOS/nixpkgs/pull/76765) replaces the gem
|
||||
# symlinks with directories, resolving this error when running rake:
|
||||
# /nix/store/451rhxkggw53h7253izpbq55nrhs7iv0-mastodon-gems-3.0.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/lib/bundler/settings.rb:6:in `<module:Bundler>': uninitialized constant Bundler::Settings (NameError)
|
||||
|
@ -48,33 +36,28 @@ stdenv.mkDerivation rec {
|
|||
'';
|
||||
};
|
||||
|
||||
mastodon-modules = stdenv.mkDerivation {
|
||||
mastodonModules = stdenv.mkDerivation {
|
||||
pname = "${pname}-modules";
|
||||
inherit src version;
|
||||
|
||||
yarnOfflineCache = fetchYarnDeps {
|
||||
yarnLock = "${src}/yarn.lock";
|
||||
sha256 = "sha256-iSqMe4B9ZEFPAw7uXgnbTWBnXg89WM/3gnDbQAUJv2E=";
|
||||
# sha256 = lib.fakeSha256;
|
||||
hash = yarnHash;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
fixup_yarn_lock
|
||||
nodejs-slim
|
||||
yarn
|
||||
mastodon-gems
|
||||
mastodon-gems.wrappedRuby
|
||||
];
|
||||
nativeBuildInputs = [ prefetch-yarn-deps nodejs-slim yarn mastodonGems mastodonGems.wrappedRuby brotli ];
|
||||
|
||||
RAILS_ENV = "production";
|
||||
NODE_ENV = "production";
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export HOME=$PWD
|
||||
# This option is needed for openssl-3 compatibility
|
||||
# Otherwise we encounter this upstream issue: https://github.com/mastodon/mastodon/issues/17924
|
||||
export NODE_OPTIONS=--openssl-legacy-provider
|
||||
fixup_yarn_lock ~/yarn.lock
|
||||
fixup-yarn-lock ~/yarn.lock
|
||||
yarn config --offline set yarn-offline-mirror $yarnOfflineCache
|
||||
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
|
||||
|
||||
|
@ -88,61 +71,99 @@ stdenv.mkDerivation rec {
|
|||
rails assets:precompile
|
||||
yarn cache clean --offline
|
||||
rm -rf ~/node_modules/.cache
|
||||
|
||||
# Create missing static gzip and brotli files
|
||||
gzip --best --keep ~/public/assets/500.html
|
||||
gzip --best --keep ~/public/packs/report.html
|
||||
find ~/public/assets -maxdepth 1 -type f -name '.*.json' \
|
||||
-exec gzip --best --keep --force {} ';'
|
||||
brotli --best --keep ~/public/packs/report.html
|
||||
find ~/public/assets -type f -regextype posix-extended -iregex '.*\.(css|js|json|html)' \
|
||||
-exec brotli --best --keep {} ';'
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/public
|
||||
cp -r node_modules $out/node_modules
|
||||
cp -r public/assets $out/public
|
||||
cp -r public/packs $out/public
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [ imagemagick ffmpeg file mastodon-gems.wrappedRuby ];
|
||||
buildInputs = [ mastodon-gems nodejs-slim ];
|
||||
propagatedBuildInputs = [ imagemagick ffmpeg file mastodonGems.wrappedRuby ];
|
||||
buildInputs = [ mastodonGems nodejs-slim ];
|
||||
|
||||
buildPhase = ''
|
||||
ln -s ${mastodon-modules}/node_modules node_modules
|
||||
ln -s ${mastodon-modules}/public/assets public/assets
|
||||
ln -s ${mastodon-modules}/public/packs public/packs
|
||||
runHook preBuild
|
||||
|
||||
ln -s $mastodonModules/node_modules node_modules
|
||||
ln -s $mastodonModules/public/assets public/assets
|
||||
ln -s $mastodonModules/public/packs public/packs
|
||||
|
||||
patchShebangs bin/
|
||||
for b in $(ls ${mastodon-gems}/bin/)
|
||||
for b in $(ls $mastodonGems/bin/)
|
||||
do
|
||||
if [ ! -f bin/$b ]; then
|
||||
ln -s ${mastodon-gems}/bin/$b bin/$b
|
||||
ln -s $mastodonGems/bin/$b bin/$b
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove execute permissions
|
||||
chmod 0444 public/emoji/*.svg
|
||||
|
||||
# Create missing static gzip and brotli files
|
||||
find public -maxdepth 1 -type f -regextype posix-extended -iregex '.*\.(css|js|svg|txt|xml)' \
|
||||
-exec gzip --best --keep --force {} ';' \
|
||||
-exec brotli --best --keep {} ';'
|
||||
find public/emoji -type f -name '.*.svg' \
|
||||
-exec gzip --best --keep --force {} ';' \
|
||||
-exec brotli --best --keep {} ';'
|
||||
ln -s assets/500.html.gz public/500.html.gz
|
||||
ln -s assets/500.html.br public/500.html.br
|
||||
ln -s packs/sw.js.gz public/sw.js.gz
|
||||
ln -s packs/sw.js.br public/sw.js.br
|
||||
ln -s packs/sw.js.map.gz public/sw.js.map.gz
|
||||
ln -s packs/sw.js.map.br public/sw.js.map.br
|
||||
|
||||
rm -rf log
|
||||
ln -s /var/log/mastodon log
|
||||
ln -s /tmp tmp
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
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
|
||||
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 ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out
|
||||
cp -r * $out/
|
||||
ln -s ${run-streaming} $out/run-streaming.sh
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tests.mastodon = nixosTests.mastodon;
|
||||
updateScript = callPackage ./update.nix { };
|
||||
# run with: nix-shell ./maintainers/scripts/update.nix --argstr package mastodon
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description =
|
||||
"Self-hosted, globally interconnected microblogging software based on ActivityPub";
|
||||
description = "Self-hosted, globally interconnected microblogging software based on ActivityPub";
|
||||
homepage = "https://joinmastodon.org";
|
||||
license = licenses.agpl3Plus;
|
||||
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
||||
maintainers = with maintainers; [ happy-river erictapen izorkin ];
|
||||
maintainers = with maintainers; [ happy-river erictapen izorkin ghuntley ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue