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