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 }:
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
16 name = "mastodon-env";
18 gemset = ./gemset.nix;
20 groups = [ "default" "production" "test" "development" ];
21 gemConfig = defaultGemConfig // {
24 sed -i 's!s\.files.*!!' redis-rack.gemspec
29 sed -i 's!s\.files.*!!' tzinfo.gemspec
33 buildInputs = [ protobuf protobufc pkgconfig ];
36 buildInputs = [ libidn ];
39 buildInputs = [ pam ];
44 packagejson = runCommand "package.json" { buildInputs = [ jq ]; } ''
45 cat ${info.src}/package.json | jq -r '.version = "${info.version}"' > $out
48 mylibs.yarn2nixPackage.mkYarnModules rec {
49 name = "mastodon-yarn";
51 version = info.version;
52 packageJSON = packagejson;
53 yarnLock = "${info.src}/yarn.lock";
54 yarnNix = ./yarn-packages.nix;
57 buildInputs = [ mylibs.yarn2nixPackage.src ];
61 npx node-gyp rebuild > build_log.txt 2>&1 || true
66 mastodon_with_yarn = stdenv.mkDerivation (info // rec {
69 cp -a ${yarnModules}/node_modules $out
71 buildInputs = [ yarnModules ];
76 inherit mastodon_with_yarn;
77 builder = writeText "build_mastodon" ''
83 cp -a $mastodon_with_yarn $out
86 chmod -R u+rwX config/ node_modules/
87 sed -i -e 's@^end$@ config.action_mailer.sendmail_settings = { location: ENV.fetch("SENDMAIL_LOCATION", "/usr/sbin/sendmail") }\nend@' config/environments/production.rb
88 RAILS_ENV=production ${gems}/bin/rails assets:precompile
90 ln -sf ${varDir}/tmp/cache tmp
92 buildInputs = [ gems gems.ruby nodejs yarn ];
93 passthru = { inherit gems varDir; };