2022-06-12 08:41:21 +00:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
pkgs,
|
2022-06-14 14:14:21 +00:00
|
|
|
} @ args: let
|
2022-06-12 08:41:21 +00:00
|
|
|
pname = "mastodon-glitch";
|
|
|
|
version = inputs.mastodon.lastModifiedDate;
|
|
|
|
src = inputs.mastodon;
|
2022-06-14 14:14:21 +00:00
|
|
|
nasin-nanpa = import ../fonts/nasin-nanpa.nix args;
|
2022-06-14 18:21:04 +00:00
|
|
|
patches = [./toki.patch];
|
2022-06-12 08:41:21 +00:00
|
|
|
in rec {
|
|
|
|
mastodon-yarn = (pkgs.callPackage ./yarn.nix {}).offline_cache;
|
|
|
|
mastodon-gems = pkgs.bundlerEnv {
|
|
|
|
name = "${pname}-gems-${version}";
|
|
|
|
inherit version;
|
|
|
|
ruby = pkgs.ruby_3_0;
|
|
|
|
gemdir = src;
|
|
|
|
gemset = ./gemset.nix;
|
|
|
|
postBuild = ''
|
|
|
|
for gem in "$out"/lib/ruby/gems/*/gems/*; do
|
|
|
|
cp -a "$gem/" "$gem.new"
|
|
|
|
rm "$gem"
|
|
|
|
# needed on macOS, otherwise the mv yields permission denied
|
|
|
|
chmod +w "$gem.new"
|
|
|
|
mv "$gem.new" "$gem"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
mastodon-modules = pkgs.stdenv.mkDerivation {
|
|
|
|
pname = "${pname}-modules";
|
2022-06-14 18:21:04 +00:00
|
|
|
inherit src version patches;
|
2022-06-12 08:41:21 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [fixup_yarn_lock nodejs-slim yarn mastodon-gems mastodon-gems.wrappedRuby];
|
|
|
|
|
|
|
|
RAILS_ENV = "production";
|
|
|
|
NODE_ENV = "production";
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
export HOME=$PWD
|
|
|
|
fixup_yarn_lock ~/yarn.lock
|
|
|
|
yarn config --offline set yarn-offline-mirror ${mastodon-yarn}
|
|
|
|
yarn install --offline --frozen-lockfile --ignore-engines --ignore-scripts --no-progress
|
|
|
|
|
|
|
|
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 --offline
|
|
|
|
rm -rf ~/node_modules/.cache
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/public
|
|
|
|
cp -r node_modules $out/node_modules
|
|
|
|
cp -r public/assets $out/public
|
|
|
|
cp -r public/packs $out/public
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
mastodon = pkgs.stdenv.mkDerivation rec {
|
2022-06-14 18:21:04 +00:00
|
|
|
inherit pname version src patches;
|
2022-06-12 08:41:21 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = with pkgs; [imagemagick ffmpeg file mastodon-gems.wrappedRuby];
|
|
|
|
buildInputs = with pkgs; [mastodon-gems 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
|
|
|
|
|
|
|
|
patchShebangs bin/
|
|
|
|
for b in $(ls ${mastodon-gems}/bin/)
|
|
|
|
do
|
|
|
|
if [ ! -f bin/$b ]; then
|
|
|
|
ln -s ${mastodon-gems}/bin/$b bin/$b
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -rf log
|
|
|
|
ln -s /var/log/mastodon log
|
|
|
|
ln -s /tmp tmp
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = let
|
|
|
|
run-streaming = pkgs.writeShellScript "run-streaming.sh" ''
|
|
|
|
# NixOS helper script to consistently use the same NodeJS version the package was built with.
|
|
|
|
${pkgs.nodejs-slim}/bin/node ./streaming
|
|
|
|
'';
|
|
|
|
in ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp -r * $out/
|
2022-06-14 14:14:21 +00:00
|
|
|
ln -s ${nasin-nanpa.nasin-nanpa-woff2} $out/public/nasin-nanpa.woff2
|
2022-06-12 08:41:21 +00:00
|
|
|
ln -s ${run-streaming} $out/run-streaming.sh
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|