-{ 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
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";
}