diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-12-13 21:25:24 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-24 01:40:13 +0200 |
commit | 252dd7d899b7a0deea1537cc5d2d48b825afffb0 (patch) | |
tree | f51c3c9cd7429b0b9553a840f26bee489be045bc /pkgs/webapps/mastodon/default.nix | |
download | NUR-nur_root.tar.gz NUR-nur_root.tar.zst NUR-nur_root.zip |
Initial commit published for NURnur_root
Diffstat (limited to 'pkgs/webapps/mastodon/default.nix')
-rw-r--r-- | pkgs/webapps/mastodon/default.nix | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/pkgs/webapps/mastodon/default.nix b/pkgs/webapps/mastodon/default.nix new file mode 100644 index 00000000..12e4c2c8 --- /dev/null +++ b/pkgs/webapps/mastodon/default.nix | |||
@@ -0,0 +1,86 @@ | |||
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 }: | ||
5 | let | ||
6 | gems = bundlerEnv { | ||
7 | name = "mastodon-env"; | ||
8 | ruby = ruby_2_6; | ||
9 | gemset = ./gemset.nix; | ||
10 | gemdir = (mylibs.fetchedGithub ./mastodon.json).src; | ||
11 | groups = [ "default" "production" "test" "development" ]; | ||
12 | gemConfig = defaultGemConfig // { | ||
13 | redis-rack = attrs: { | ||
14 | preBuild = '' | ||
15 | sed -i 's!s\.files.*!!' redis-rack.gemspec | ||
16 | ''; | ||
17 | }; | ||
18 | tzinfo = attrs: { | ||
19 | preBuild = '' | ||
20 | sed -i 's!s\.files.*!!' tzinfo.gemspec | ||
21 | ''; | ||
22 | }; | ||
23 | cld3 = attrs: { | ||
24 | buildInputs = [ protobuf protobufc pkgconfig ]; | ||
25 | }; | ||
26 | idn-ruby = attrs: { | ||
27 | buildInputs = [ libidn ]; | ||
28 | }; | ||
29 | rpam2 = attrs: { | ||
30 | buildInputs = [ pam ]; | ||
31 | }; | ||
32 | }; | ||
33 | }; | ||
34 | yarnModules = let | ||
35 | info = mylibs.fetchedGithub ./mastodon.json; | ||
36 | packagejson = runCommand "package.json" { buildInputs = [ jq ]; } '' | ||
37 | cat ${info.src}/package.json | jq -r '.version = "${info.version}"' > $out | ||
38 | ''; | ||
39 | in | ||
40 | mylibs.yarn2nixPackage.mkYarnModules rec { | ||
41 | name = "mastodon-yarn"; | ||
42 | pname = name; | ||
43 | version = info.version; | ||
44 | packageJSON = packagejson; | ||
45 | yarnLock = "${info.src}/yarn.lock"; | ||
46 | yarnNix = ./yarn-packages.nix; | ||
47 | pkgConfig = { | ||
48 | all = { | ||
49 | buildInputs = [ mylibs.yarn2nixPackage.src ]; | ||
50 | }; | ||
51 | uws = { | ||
52 | postInstall = '' | ||
53 | npx node-gyp rebuild > build_log.txt 2>&1 || true | ||
54 | ''; | ||
55 | }; | ||
56 | }; | ||
57 | }; | ||
58 | mastodon_with_yarn = stdenv.mkDerivation (mylibs.fetchedGithub ./mastodon.json // rec { | ||
59 | installPhase = '' | ||
60 | cp -a . $out | ||
61 | cp -a ${yarnModules}/node_modules $out | ||
62 | ''; | ||
63 | buildInputs = [ yarnModules ]; | ||
64 | }); | ||
65 | in | ||
66 | stdenv.mkDerivation { | ||
67 | name = "mastodon"; | ||
68 | inherit mastodon_with_yarn; | ||
69 | builder = writeText "build_mastodon" '' | ||
70 | source $stdenv/setup | ||
71 | set -a | ||
72 | SECRET_KEY_BASE=Dummy | ||
73 | OTP_SECRET=Dummy | ||
74 | set +a | ||
75 | cp -a $mastodon_with_yarn $out | ||
76 | cd $out | ||
77 | chmod u+rwX . public | ||
78 | chmod -R u+rwX config/ | ||
79 | sed -i -e 's@^end$@ config.action_mailer.sendmail_settings = { location: ENV.fetch("SENDMAIL_LOCATION", "/usr/sbin/sendmail") }\nend@' config/environments/production.rb | ||
80 | RAILS_ENV=production ${gems}/bin/rails assets:precompile | ||
81 | rm -rf tmp/cache | ||
82 | ln -sf ${varDir}/tmp/cache tmp | ||
83 | ''; | ||
84 | buildInputs = [ gems gems.ruby nodejs yarn ]; | ||
85 | passthru = { inherit gems varDir; }; | ||
86 | } | ||