X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=virtual%2Fmodules%2Fwebsites%2Ftools%2Fmastodon%2Fmastodon.nix;h=c2c180727fd12f23322ff1b13b436f7cecc9425b;hb=2ff7e086a363abdf8054f796f3cd5cd93b8af5be;hp=463de1cce883f7215816cb262fe02e332df0ac76;hpb=159d8ff3f05b0ba7dc65b23f5a7b30ddfc59d13f;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/virtual/modules/websites/tools/mastodon/mastodon.nix b/virtual/modules/websites/tools/mastodon/mastodon.nix index 463de1c..c2c1807 100644 --- a/virtual/modules/websites/tools/mastodon/mastodon.nix +++ b/virtual/modules/websites/tools/mastodon/mastodon.nix @@ -1,25 +1,35 @@ -{ env, fetchedGithub, stdenv, writeText, pkgs, cacert }: +{ env, ruby_2_5, bundlerEnv, defaultGemConfig, fetchedGithub, stdenv, writeText, pkgs, cacert }: let varDir = "/var/lib/mastodon_immae"; socketsDir = "/run/mastodon"; + gems = bundlerEnv { + name = "mastodon-env"; + ruby = ruby_2_5; + gemset = ./gemset.nix; + gemdir = (fetchedGithub ./mastodon.json).src; + groups = [ "default" "production" "test" "development" ]; + gemConfig = defaultGemConfig // { + cld3 = attrs: { + buildInputs = with pkgs; [ protobuf protobufc pkgconfig ]; + }; + idn-ruby = attrs: { + buildInputs = with pkgs; [ libidn ]; + }; + rpam2 = attrs: { + buildInputs = with pkgs; [ pam ]; + }; + }; + }; mastodon = stdenv.mkDerivation (fetchedGithub ./mastodon.json // rec { + __noChroot = true; buildPhase = '' - export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt - export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt - - bundle install --deployment --without development test yarn install --pure-lockfile + patchShebangs node_modules ''; installPhase = '' cp -a . $out ''; - propagatedBuildInputs = with pkgs; [ - zlib icu libchardet git bundler yarn - protobuf protobufc libidn libpqxx nodejs - imagemagick ffmpeg libxml2 libxslt pkgconfig - autoconf bison libyaml readline ncurses libffi gdbm - jemalloc which postgresql python3 cacert - ]; + propagatedBuildInputs = [ gems pkgs.yarn pkgs.python2 pkgs.nodejs ]; }); config = writeText "mastodon_environment" '' REDIS_HOST=localhost @@ -73,19 +83,15 @@ let cp -a $mastodon $out cd $out chmod u+rwX . node_modules public - RAILS_ENV=production bundle exec rails assets:precompile + RAILS_ENV=production ${gems}/bin/rails assets:precompile + rm -rf tmp/cache + ln -sf ../../../../../../../${varDir}/tmp/cache tmp ''; - propagatedBuildInputs = with pkgs; [ - zlib icu libchardet git bundler yarn - protobuf protobufc libidn libpqxx nodejs - imagemagick ffmpeg libxml2 libxslt pkgconfig - autoconf bison libyaml readline ncurses libffi gdbm - jemalloc which postgresql python3 cacert - ]; + buildInputs = [ gems pkgs.nodejs pkgs.yarn ]; }; in { - inherit railsRoot config varDir socketsDir; + inherit railsRoot config varDir socketsDir gems; nodeSocket = "${socketsDir}/live_immae_node.sock"; railsSocket = "${socketsDir}/live_immae_puma.sock"; }