1 { varDir ? "/var/lib/mastodon", mylibs,
2 stdenv, writeText, runCommand,
3 ruby_2_6, bundlerEnv, defaultGemConfig,
4 jq, protobuf, protobufc, pkgconfig, libidn, pam, nodejs, yarn, yarn2nix-moretea }:
6 info = mylibs.fetchedGithub ./mastodon.json // {
7 src = runCommand "mastodon-patched" {
8 source = (mylibs.fetchedGithub ./mastodon.json).src;
12 sed -i -e "/fuubar/s/2.4.0/2.4.1/" $out/Gemfile.lock
13 sed -i -e "s/ff00dc470b5b2d9f145a6d6e977a54de5df2b4c9/ff00dc470b5b2d9f145a6d6e977a54de5df2b4c9#4255dc41fa7df9c3a02c1595f058e248bc37b784/" $out/yarn.lock
17 name = "mastodon-env";
19 gemset = ./gemset.nix;
21 groups = [ "default" "production" "test" "development" ];
22 gemConfig = defaultGemConfig // {
25 sed -i 's!s\.files.*!!' redis-rack.gemspec
30 sed -i 's!s\.files.*!!' tzinfo.gemspec
34 buildInputs = [ protobuf protobufc pkgconfig ];
37 buildInputs = [ libidn ];
40 buildInputs = [ pam ];
45 packagejson = runCommand "package.json" { buildInputs = [ jq ]; } ''
46 cat ${info.src}/package.json | jq -r '.version = "${info.version}"' > $out
49 yarn2nix-moretea.mkYarnModules rec {
50 name = "mastodon-yarn";
52 version = info.version;
53 packageJSON = packagejson;
54 yarnLock = "${info.src}/yarn.lock";
55 yarnNix = ./yarn-packages.nix;
59 npx node-gyp rebuild > build_log.txt 2>&1 || true
64 mastodon_with_yarn = stdenv.mkDerivation (info // rec {
67 cp -a ${yarnModules}/node_modules $out
69 buildInputs = [ yarnModules ];
74 inherit mastodon_with_yarn;
75 builder = writeText "build_mastodon" ''
81 cp -a $mastodon_with_yarn $out
84 chmod -R u+rwX config/ node_modules/
85 sed -i -e 's@^end$@ config.action_mailer.sendmail_settings = { location: ENV.fetch("SENDMAIL_LOCATION", "/usr/sbin/sendmail") }\nend@' config/environments/production.rb
86 RAILS_ENV=production ${gems}/bin/rails assets:precompile
88 ln -sf ${varDir}/tmp/cache tmp
90 buildInputs = [ gems gems.ruby nodejs yarn ];
91 passthru = { inherit gems varDir; };