loomio-nix/pkg/loomio/default.nix

63 lines
1.2 KiB
Nix
Raw Normal View History

{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 {};
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:
adapter: postgresql
database: <%= ENV['LOOMIO_DATABASE'] %>
host: /var/run/postgresql
2024-08-23 08:24:36 +00:00
'';
2024-04-05 12:19:55 +00:00
in stdenv.mkDerivation {
name = "loomio";
inherit src;
nativeBuildInputs = [ gems gems.wrappedRuby ];
2024-04-05 12:19:55 +00:00
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
'';
2024-04-05 12:19:55 +00:00
installPhase = ''
mkdir -p $out
cp -r * $out
2024-04-05 12:19:55 +00:00
'';
}