loomio-nix/pkg/loomio/default.nix
Akshay Mankar 8d707f9a53
Get loomio server to start
Crashes immediately on hitting any route because vue js stuff is not compiled
yet.
2024-08-24 21:18:34 +02:00

63 lines
1.2 KiB
Nix

{stdenv,
writeShellScriptBin,
writeText,
symlinkJoin,
callPackage,
bundlerEnv,
ruby_3_2,
postgresql
}:
let
gemfile-patch = callPackage ./gemfile-patch.nix {};
src = callPackage ./source.nix {
patches = [
gemfile-patch
./creds.patch
];
};
gems = bundlerEnv {
name = "loomio-env";
ruby = ruby_3_2;
gemset = ./. + "/gemset.nix";
gemdir = src;
};
databaseConfig = writeText "database.yml" ''
production:
adapter: postgresql
database: <%= ENV['LOOMIO_DATABASE'] %>
host: /var/run/postgresql
'';
in stdenv.mkDerivation {
name = "loomio";
inherit src;
nativeBuildInputs = [ gems gems.wrappedRuby ];
buildInputs = [gems ruby_3_2];
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
'';
installPhase = ''
mkdir -p $out
cp -r * $out
'';
}