2024-08-23 08:24:36 +00:00
|
|
|
{stdenv, writeText, callPackage, bundlerEnv, ruby_3_2 }:
|
2024-04-05 12:19:55 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
gemfile-patch = callPackage ./gemfile-patch.nix {};
|
|
|
|
src = callPackage ./source.nix { patches = [gemfile-patch];};
|
|
|
|
gems = bundlerEnv {
|
|
|
|
name = "loomio-env";
|
|
|
|
ruby = ruby_3_2;
|
|
|
|
gemset = ./. + "/gemset.nix";
|
|
|
|
gemdir = src;
|
|
|
|
};
|
2024-08-23 08:24:36 +00:00
|
|
|
|
|
|
|
databaseConfig = writeText "database.yml" ''
|
|
|
|
production:
|
|
|
|
url: <%= ENV['DATABASE_URL'] %>
|
|
|
|
'';
|
2024-04-05 12:19:55 +00:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
name = "loomio";
|
|
|
|
inherit src;
|
|
|
|
buildInputs = [gems ruby_3_2];
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/{bin,share/loomio}
|
|
|
|
cp -r * $out/share/loomio
|
|
|
|
bin=$out/bin/loomio
|
2024-08-23 08:24:36 +00:00
|
|
|
cp ${databaseConfig} $out/share/loomio/config/database.yml
|
2024-04-05 12:19:55 +00:00
|
|
|
cat > $bin <<EOF
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-04-27 23:29:26 +00:00
|
|
|
set -ex
|
2024-04-05 12:19:55 +00:00
|
|
|
export BUNDLE_FORCE_RUBY_PLATFORM=true
|
2024-08-23 08:24:36 +00:00
|
|
|
export RAILS_ENV=production
|
2024-04-27 23:29:26 +00:00
|
|
|
${gems}/bin/bundle exec rake -f $out/share/loomio/Rakefile db:prepare
|
|
|
|
${gems}/bin/bundle exec puma -C $out/share/loomio/config/puma.rb
|
2024-04-05 12:19:55 +00:00
|
|
|
|
|
|
|
EOF
|
2024-04-27 23:29:26 +00:00
|
|
|
|
2024-04-05 12:19:55 +00:00
|
|
|
chmod +x $bin
|
|
|
|
'';
|
|
|
|
}
|