2024-08-24 19:18:34 +00:00
|
|
|
{stdenv,
|
|
|
|
writeShellScriptBin,
|
|
|
|
writeText,
|
|
|
|
symlinkJoin,
|
|
|
|
callPackage,
|
|
|
|
bundlerEnv,
|
|
|
|
ruby_3_2,
|
|
|
|
postgresql
|
|
|
|
}:
|
2024-04-05 12:19:55 +00:00
|
|
|
let
|
|
|
|
gemfile-patch = callPackage ./gemfile-patch.nix {};
|
2024-08-24 19:18:34 +00:00
|
|
|
src = callPackage ./source.nix {
|
|
|
|
patches = [
|
|
|
|
gemfile-patch
|
|
|
|
./creds.patch
|
|
|
|
];
|
|
|
|
};
|
2024-04-05 12:19:55 +00:00
|
|
|
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:
|
2024-08-24 19:18:34 +00:00
|
|
|
adapter: postgresql
|
|
|
|
database: <%= ENV['LOOMIO_DATABASE'] %>
|
|
|
|
host: /var/run/postgresql
|
2024-08-23 08:24:36 +00:00
|
|
|
'';
|
2024-08-24 19:18:34 +00:00
|
|
|
|
2024-04-05 12:19:55 +00:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
name = "loomio";
|
|
|
|
inherit src;
|
2024-08-24 19:18:34 +00:00
|
|
|
nativeBuildInputs = [ gems gems.wrappedRuby ];
|
2024-04-05 12:19:55 +00:00
|
|
|
buildInputs = [gems ruby_3_2];
|
2024-08-24 19:18:34 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
cp ${databaseConfig} config/database.yml
|
|
|
|
cp ${./puma.rb} config/puma.rb
|
|
|
|
|
|
|
|
export BUNDLE_FORCE_RUBY_PLATFORM=true
|
|
|
|
${gems}/bin/bundle exec bootsnap precompile --gemfile app/ lib/
|
|
|
|
|
|
|
|
patchShebangs bin/
|
|
|
|
|
|
|
|
for b in $(ls ${gems}/bin/)
|
|
|
|
do
|
|
|
|
if [ ! -f bin/$b ]; then
|
|
|
|
ln -s ${gems}/bin/$b bin/$b
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
2024-04-05 12:19:55 +00:00
|
|
|
installPhase = ''
|
2024-08-24 19:18:34 +00:00
|
|
|
mkdir -p $out
|
|
|
|
cp -r * $out
|
2024-04-05 12:19:55 +00:00
|
|
|
'';
|
|
|
|
}
|