diff options
Diffstat (limited to 'virtual/modules/websites/tools/mastodon/mastodon.nix')
-rw-r--r-- | virtual/modules/websites/tools/mastodon/mastodon.nix | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/virtual/modules/websites/tools/mastodon/mastodon.nix b/virtual/modules/websites/tools/mastodon/mastodon.nix index c2c1807..cb8bfc8 100644 --- a/virtual/modules/websites/tools/mastodon/mastodon.nix +++ b/virtual/modules/websites/tools/mastodon/mastodon.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { env, ruby_2_5, bundlerEnv, defaultGemConfig, fetchedGithub, stdenv, writeText, pkgs, cacert }: | 1 | { env, ruby_2_5, bundlerEnv, defaultGemConfig, fetchedGithub, stdenv, writeText, pkgs }: |
2 | let | 2 | let |
3 | varDir = "/var/lib/mastodon_immae"; | 3 | varDir = "/var/lib/mastodon_immae"; |
4 | socketsDir = "/run/mastodon"; | 4 | socketsDir = "/run/mastodon"; |
@@ -20,16 +20,48 @@ let | |||
20 | }; | 20 | }; |
21 | }; | 21 | }; |
22 | }; | 22 | }; |
23 | yarnModules = let | ||
24 | info = fetchedGithub ./mastodon.json; | ||
25 | in | ||
26 | pkgs.yarn2nix.mkYarnModules { | ||
27 | name = "mastodon-yarn-modules"; | ||
28 | packageJSON = "${info.src}/package.json"; | ||
29 | yarnLock = "${info.src}/yarn.lock"; | ||
30 | yarnNix = ./yarn-packages.nix; | ||
31 | pkgConfig = { | ||
32 | uws = { | ||
33 | postInstall = '' | ||
34 | node-gyp rebuild > build_log.txt 2>&1 || true | ||
35 | ''; | ||
36 | buildInputs = with pkgs; [ nodePackages.node-gyp ]; | ||
37 | }; | ||
38 | node-zopfli = { | ||
39 | postInstall = '' | ||
40 | node-pre-gyp install --fallback-to-build | ||
41 | ''; | ||
42 | buildInputs = with pkgs; [ nodePackages.node-pre-gyp ]; | ||
43 | }; | ||
44 | node-sass = { | ||
45 | buildInputs = with pkgs; [ binutils libsass python ]; | ||
46 | postInstall = let | ||
47 | nodeHeaders = pkgs.fetchurl { | ||
48 | url = "https://nodejs.org/download/release/v${pkgs.nodejs.version}/node-v${pkgs.nodejs.version}-headers.tar.gz"; | ||
49 | sha256 = "12zzsf8my43b8qnlacp871ih5vqafl2vlpqp51xp6h3gckn2frwy"; | ||
50 | }; | ||
51 | in | ||
52 | '' | ||
53 | export AR=${pkgs.binutils.bintools}/bin/ar | ||
54 | node scripts/build.js --tarball=${nodeHeaders} | ||
55 | ''; | ||
56 | }; | ||
57 | }; | ||
58 | }; | ||
23 | mastodon = stdenv.mkDerivation (fetchedGithub ./mastodon.json // rec { | 59 | mastodon = stdenv.mkDerivation (fetchedGithub ./mastodon.json // rec { |
24 | __noChroot = true; | ||
25 | buildPhase = '' | ||
26 | yarn install --pure-lockfile | ||
27 | patchShebangs node_modules | ||
28 | ''; | ||
29 | installPhase = '' | 60 | installPhase = '' |
30 | cp -a . $out | 61 | cp -a . $out |
62 | cp -a ${yarnModules}/node_modules $out | ||
31 | ''; | 63 | ''; |
32 | propagatedBuildInputs = [ gems pkgs.yarn pkgs.python2 pkgs.nodejs ]; | 64 | buildInputs = [ yarnModules gems ]; |
33 | }); | 65 | }); |
34 | config = writeText "mastodon_environment" '' | 66 | config = writeText "mastodon_environment" '' |
35 | REDIS_HOST=localhost | 67 | REDIS_HOST=localhost |
@@ -82,12 +114,12 @@ let | |||
82 | set +a | 114 | set +a |
83 | cp -a $mastodon $out | 115 | cp -a $mastodon $out |
84 | cd $out | 116 | cd $out |
85 | chmod u+rwX . node_modules public | 117 | chmod u+rwX . public |
86 | RAILS_ENV=production ${gems}/bin/rails assets:precompile | 118 | RAILS_ENV=production ${gems}/bin/rails assets:precompile |
87 | rm -rf tmp/cache | 119 | rm -rf tmp/cache |
88 | ln -sf ../../../../../../../${varDir}/tmp/cache tmp | 120 | ln -sf ../../../../../../../${varDir}/tmp/cache tmp |
89 | ''; | 121 | ''; |
90 | buildInputs = [ gems pkgs.nodejs pkgs.yarn ]; | 122 | buildInputs = [ gems gems.ruby pkgs.nodejs pkgs.yarn ]; |
91 | }; | 123 | }; |
92 | in | 124 | in |
93 | { | 125 | { |