]>
Commit | Line | Data |
---|---|---|
bc0f9fcf IB |
1 | { varDir ? "/var/lib/mastodon", |
2 | stdenv, src, writeText, runCommand, | |
20e1428f | 3 | ruby_2_6, bundlerEnv, defaultGemConfig, |
71b4786d | 4 | jq, protobuf, protobufc, pkgconfig, libidn, pam, nodejs, yarn, yarn2nix-moretea }: |
20e1428f | 5 | let |
bc0f9fcf IB |
6 | patched = runCommand "mastodon-patched" { |
7 | source = src; | |
6551e648 IB |
8 | } '' |
9 | cp -a $source $out | |
10 | chmod -R u+w $out | |
11 | sed -i -e "/fuubar/s/2.4.0/2.4.1/" $out/Gemfile.lock | |
71b4786d | 12 | sed -i -e "s/ff00dc470b5b2d9f145a6d6e977a54de5df2b4c9/ff00dc470b5b2d9f145a6d6e977a54de5df2b4c9#4255dc41fa7df9c3a02c1595f058e248bc37b784/" $out/yarn.lock |
6551e648 | 13 | ''; |
20e1428f IB |
14 | gems = bundlerEnv { |
15 | name = "mastodon-env"; | |
16 | ruby = ruby_2_6; | |
17 | gemset = ./gemset.nix; | |
bc0f9fcf | 18 | gemdir = patched; |
20e1428f IB |
19 | groups = [ "default" "production" "test" "development" ]; |
20 | gemConfig = defaultGemConfig // { | |
21 | redis-rack = attrs: { | |
22 | preBuild = '' | |
23 | sed -i 's!s\.files.*!!' redis-rack.gemspec | |
24 | ''; | |
25 | }; | |
26 | tzinfo = attrs: { | |
27 | preBuild = '' | |
28 | sed -i 's!s\.files.*!!' tzinfo.gemspec | |
29 | ''; | |
30 | }; | |
31 | cld3 = attrs: { | |
32 | buildInputs = [ protobuf protobufc pkgconfig ]; | |
33 | }; | |
34 | idn-ruby = attrs: { | |
35 | buildInputs = [ libidn ]; | |
36 | }; | |
37 | rpam2 = attrs: { | |
38 | buildInputs = [ pam ]; | |
39 | }; | |
40 | }; | |
41 | }; | |
42 | yarnModules = let | |
20e1428f | 43 | packagejson = runCommand "package.json" { buildInputs = [ jq ]; } '' |
bc0f9fcf | 44 | cat ${patched}/package.json | jq -r '.version = "${src.version}"' > $out |
20e1428f IB |
45 | ''; |
46 | in | |
71b4786d | 47 | yarn2nix-moretea.mkYarnModules rec { |
20e1428f IB |
48 | name = "mastodon-yarn"; |
49 | pname = name; | |
bc0f9fcf | 50 | version = src.version; |
20e1428f | 51 | packageJSON = packagejson; |
bc0f9fcf | 52 | yarnLock = "${patched}/yarn.lock"; |
20e1428f IB |
53 | yarnNix = ./yarn-packages.nix; |
54 | pkgConfig = { | |
20e1428f IB |
55 | uws = { |
56 | postInstall = '' | |
57 | npx node-gyp rebuild > build_log.txt 2>&1 || true | |
58 | ''; | |
59 | }; | |
60 | }; | |
61 | }; | |
bc0f9fcf IB |
62 | mastodon_with_yarn = stdenv.mkDerivation { |
63 | pname = "mastodon"; | |
64 | version = src.version; | |
65 | inherit src; | |
eb14b976 IB |
66 | installPhase = '' |
67 | cp -a . $out | |
68 | cp -a ${yarnModules}/node_modules $out | |
69 | ''; | |
70 | buildInputs = [ yarnModules ]; | |
bc0f9fcf | 71 | }; |
20e1428f IB |
72 | in |
73 | stdenv.mkDerivation { | |
74 | name = "mastodon"; | |
75 | inherit mastodon_with_yarn; | |
76 | builder = writeText "build_mastodon" '' | |
77 | source $stdenv/setup | |
78 | set -a | |
79 | SECRET_KEY_BASE=Dummy | |
80 | OTP_SECRET=Dummy | |
81 | set +a | |
82 | cp -a $mastodon_with_yarn $out | |
83 | cd $out | |
84 | chmod u+rwX . public | |
6551e648 | 85 | chmod -R u+rwX config/ node_modules/ |
20e1428f IB |
86 | sed -i -e 's@^end$@ config.action_mailer.sendmail_settings = { location: ENV.fetch("SENDMAIL_LOCATION", "/usr/sbin/sendmail") }\nend@' config/environments/production.rb |
87 | RAILS_ENV=production ${gems}/bin/rails assets:precompile | |
88 | rm -rf tmp/cache | |
89 | ln -sf ${varDir}/tmp/cache tmp | |
90 | ''; | |
91 | buildInputs = [ gems gems.ruby nodejs yarn ]; | |
bc0f9fcf | 92 | passthru = { inherit gems varDir nodejs; }; |
20e1428f | 93 | } |