forked from emily/nixfiles
nyastodon: v4.3.0-alpha.3+glitch+cat+1.0.0+nya-1.2.2 → 4.3.0-alpha.5+glitch+cat+1.0.8
This commit is contained in:
parent
a75ab9df9c
commit
fcf0e28b1d
5 changed files with 737 additions and 498 deletions
|
@ -1,161 +1,28 @@
|
||||||
{ lib, stdenv, nodejs-slim, bundlerEnv, nixosTests
|
{
|
||||||
, yarn-berry, callPackage, ruby, writeShellScript
|
callPackage,
|
||||||
, brotli
|
mastodon,
|
||||||
|
patches ? [],
|
||||||
# Allow building a fork or custom version of Mastodon:
|
|
||||||
, pname ? "nyastodon"
|
|
||||||
, version ? srcOverride.version
|
|
||||||
, patches ? []
|
|
||||||
# src is a package
|
|
||||||
, srcOverride ? callPackage ./source.nix { inherit patches; }
|
|
||||||
, gemset ? ./. + "/gemset.nix"
|
|
||||||
, yarnHash ? srcOverride.yarnHash
|
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
stdenv.mkDerivation rec {
|
src = callPackage ./source.nix {
|
||||||
inherit pname version;
|
inherit patches;
|
||||||
|
|
||||||
src = srcOverride;
|
|
||||||
|
|
||||||
mastodonGems = bundlerEnv {
|
|
||||||
name = "${pname}-gems-${version}";
|
|
||||||
inherit version gemset ruby;
|
|
||||||
gemdir = src;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mastodonModules = stdenv.mkDerivation {
|
yarn-deps = callPackage ./yarn.nix {
|
||||||
pname = "${pname}-modules";
|
inherit src;
|
||||||
inherit src version;
|
hash = src.yarnHash;
|
||||||
|
|
||||||
yarnOfflineCache = callPackage ./yarn.nix {
|
|
||||||
src = srcOverride;
|
|
||||||
hash = yarnHash;
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = [ nodejs-slim yarn-berry 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
|
|
||||||
|
|
||||||
export YARN_ENABLE_TELEMETRY=0
|
|
||||||
mkdir -p ~/.yarn/berry
|
|
||||||
ln -sf $yarnOfflineCache ~/.yarn/berry/cache
|
|
||||||
|
|
||||||
yarn install --immutable --immutable-cache
|
|
||||||
|
|
||||||
patchShebangs ~/bin
|
|
||||||
patchShebangs ~/node_modules
|
|
||||||
|
|
||||||
# skip running yarn install
|
|
||||||
rm -rf ~/bin/yarn
|
|
||||||
|
|
||||||
OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder \
|
|
||||||
rails assets:precompile
|
|
||||||
yarn cache clean
|
|
||||||
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 = [ mastodonGems.wrappedRuby ];
|
nyastodon = mastodon.override {
|
||||||
nativeBuildInputs = [ brotli ];
|
pname = "nyastodon";
|
||||||
buildInputs = [ mastodonGems nodejs-slim ];
|
srcOverride = src;
|
||||||
|
gemset = ./gemset.nix;
|
||||||
buildPhase = ''
|
|
||||||
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 $mastodonGems/bin/)
|
|
||||||
do
|
|
||||||
if [ ! -f bin/$b ]; then
|
|
||||||
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 ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
mkdir -p $out
|
|
||||||
cp -r * $out/
|
|
||||||
ln -s ${run-streaming} $out/run-streaming.sh
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
tests.mastodon = nixosTests.mastodon;
|
|
||||||
# run with: nix-shell ./maintainers/scripts/update.nix --argstr package mastodon
|
|
||||||
updateScript = ./update.sh;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
modules = callPackage ./modules.nix {
|
||||||
description = "Self-hosted, globally interconnected microblogging software based on ActivityPub";
|
inherit nyastodon yarn-deps;
|
||||||
homepage = "https://joinmastodon.org";
|
|
||||||
license = licenses.agpl3Plus;
|
|
||||||
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
|
||||||
maintainers = with maintainers; [ happy-river erictapen izorkin ghuntley ];
|
|
||||||
};
|
};
|
||||||
}
|
in
|
||||||
|
nyastodon.overrideAttrs (_: {
|
||||||
|
mastodonModules = modules;
|
||||||
|
})
|
||||||
|
|
File diff suppressed because it is too large
Load diff
75
pkgs/nyastodon/modules.nix
Normal file
75
pkgs/nyastodon/modules.nix
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
# copied from https://git.catgirl.cloud/999eagle/dotfiles-nix/-/blob/main/overlay/mastodon/glitch/modules.nix
|
||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
nodejs-slim,
|
||||||
|
yarn-berry,
|
||||||
|
brotli,
|
||||||
|
# previous inputs
|
||||||
|
nyastodon,
|
||||||
|
yarn-deps,
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "glitch-modules";
|
||||||
|
inherit (nyastodon) src version;
|
||||||
|
|
||||||
|
yarnOfflineCache = yarn-deps;
|
||||||
|
|
||||||
|
nativeBuildInputs = [nyastodon.mastodonGems nyastodon.mastodonGems.wrappedRuby] ++ [nodejs-slim yarn-berry 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
|
||||||
|
|
||||||
|
export YARN_ENABLE_TELEMETRY=0
|
||||||
|
# what the actual *fuck* https://github.com/yarnpkg/berry/issues/6309
|
||||||
|
export UV_USE_IO_URING=0
|
||||||
|
mkdir -p ~/.yarn/berry
|
||||||
|
ln -sf $yarnOfflineCache ~/.yarn/berry/cache
|
||||||
|
|
||||||
|
yarn install --immutable --immutable-cache
|
||||||
|
|
||||||
|
patchShebangs ~/bin
|
||||||
|
patchShebangs ~/node_modules
|
||||||
|
|
||||||
|
# skip running yarn install
|
||||||
|
rm -rf ~/bin/yarn
|
||||||
|
|
||||||
|
OTP_SECRET=precompile_placeholder \
|
||||||
|
SECRET_KEY_BASE=precompile_placeholder \
|
||||||
|
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=precompile_placeholder \
|
||||||
|
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=precompile_placeholder \
|
||||||
|
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=precompile_placeholder \
|
||||||
|
rails assets:precompile
|
||||||
|
yarn cache clean
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
# This file was generated by pkgs.mastodon.updateScript.
|
# This file was generated by pkgs.mastodon.updateScript.
|
||||||
{ fetchgit, applyPatches, patches ? [] }:
|
{ lib, fetchgit, applyPatches, patches ? [] }:
|
||||||
let
|
let
|
||||||
version = "v4.3.0-alpha.3+glitch+cat+1.0.0+nya-1.2.2";
|
version = "4.3.0-alpha.5+glitch+cat+1.0.8";
|
||||||
in
|
in
|
||||||
(
|
(
|
||||||
applyPatches {
|
applyPatches {
|
||||||
src = fetchgit {
|
src = fetchgit {
|
||||||
url = "https://woof.rip/mirrors/nyastodon.git";
|
url = "https://woof.rip/mirrors/catstodon.git";
|
||||||
rev = "refs/heads/develop";
|
rev = "7d8714db8135f5c3dfc81964887248d76a797788";
|
||||||
hash = "sha256-YFQPzsqJxGOS4E/1+chB+C7vD+NlgFiRekDsGZdcL9c=";
|
hash = "sha256-VPXsIRAZxNOaLRI+g2gDy582BYx5t/SHv4xIrGAFTz0=";
|
||||||
};
|
};
|
||||||
patches = patches ++ [];
|
patches = patches ++ [];
|
||||||
}) // {
|
}) // {
|
||||||
inherit version;
|
inherit version;
|
||||||
yarnHash = "sha256-XYTQaeSCaws9pR2QAYX2Y4F4BXLdQdBwYV9rCE3tYRA=";
|
yarnHash = "sha256-kkjRYQPjWB1udlpIH2Q+a+bbiqXw1T/dgv3KmQk/YBY=";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#! nix-shell -i bash -p bundix coreutils diffutils nix-prefetch-git gnused jq prefetch-yarn-deps yarn-lock-converter
|
#! nix-shell -i bash -p bundix coreutils diffutils nix-prefetch-git gnused jq prefetch-yarn-deps yarn-lock-converter
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
URL=https://woof.rip/mirrors/nyastodon.git
|
URL=https://woof.rip/mirrors/catstodon.git
|
||||||
|
|
||||||
POSITIONAL=()
|
POSITIONAL=()
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
@ -79,7 +79,7 @@ HASH=$(echo "$JSON" | jq -r .hash)
|
||||||
|
|
||||||
cat > source.nix << EOF
|
cat > source.nix << EOF
|
||||||
# This file was generated by pkgs.mastodon.updateScript.
|
# This file was generated by pkgs.mastodon.updateScript.
|
||||||
{ fetchgit, applyPatches, patches ? [] }:
|
{ lib, fetchgit, applyPatches, patches ? [] }:
|
||||||
let
|
let
|
||||||
version = "$VERSION";
|
version = "$VERSION";
|
||||||
in
|
in
|
||||||
|
@ -93,7 +93,7 @@ in
|
||||||
patches = patches ++ [$PATCHES];
|
patches = patches ++ [$PATCHES];
|
||||||
}) // {
|
}) // {
|
||||||
inherit version;
|
inherit version;
|
||||||
yarnHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
yarnHash = lib.fakeHash;
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
SOURCE_DIR="$(nix-build --no-out-link -E '(import <nixpkgs> {}).callPackage ./source.nix {}')"
|
SOURCE_DIR="$(nix-build --no-out-link -E '(import <nixpkgs> {}).callPackage ./source.nix {}')"
|
||||||
|
|
Loading…
Reference in a new issue