stuebinm
0127bbefcd
This adds an instance of wink for the hacc-voc to hainich. Unfortunately, neither the actual package nor the container itself look very nixy, and e.g. cannot be configured declaratively. On the other hand, it does not appear the wink *has* any kind of config, so I guess there's that. Wink itself runs in a nixos container, but I've exposed its database to /var/lib/wink-db on the host, just to make it easier to access. After deployment, we still need to migrate our current database to this instance by hand (i.e. take the current database, rename it "development.sqlite3", and move it into the wink-db directory). Any improvements to this mess are welcome.
96 lines
2.6 KiB
Nix
96 lines
2.6 KiB
Nix
|
|
# high-level notes:
|
|
# - wink uses the execjs gem, which needs some javascript runtime
|
|
# to be available. Wink usually uses the mini_racer gem for this,
|
|
# which unfortunately refuses to work on nix, so instead we have
|
|
# to patch it out of wink's dependencies and replace it with
|
|
# something else
|
|
# - execjs actually just takes any compatible js runtime it can find;
|
|
# this packages uses v8 by default, but you can easily override it
|
|
# with e.g. nodejs and wink should still work.
|
|
|
|
{ stdenv
|
|
, bundlerEnv
|
|
, fetchFromGitHub
|
|
, zlib
|
|
, sqlite
|
|
, ruby
|
|
, makeWrapper
|
|
# v8 may be replaced with e.g. nodejs — see docs for execjs for a list
|
|
# of accaptable backends, all of which should all work out of the box
|
|
, v8
|
|
, ... }:
|
|
|
|
let
|
|
sources-patched = stdenv.mkDerivation {
|
|
name = "wink-sources-patched";
|
|
|
|
# wink sources from the c3VOC
|
|
src = fetchFromGitHub {
|
|
owner = "voc";
|
|
repo = "wink";
|
|
rev = "9f1d312b7bf6457fc23aaa9348a43c3900046a6c";
|
|
sha256 = "1xyb4n4ys93mzyj779mdd6ngiials38xfql3ivddxc1l5rk11hbi";
|
|
};
|
|
|
|
phases = [ "patchPhase" "installPhase" ];
|
|
|
|
# remove mini_racer and libv8 (its sole dependency) from wink's deps
|
|
patchPhase = ''
|
|
cp -r $src/* .
|
|
sed -i "s/gem 'mini_racer', platforms: :ruby/#removed mini_racer/g" Gemfile
|
|
sed -i "s/mini_racer (0.2.0)/ /g" Gemfile.lock
|
|
sed -i "s/libv8 (>= 6.3)/ /g" Gemfile.lock
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp -r * $out/
|
|
'';
|
|
};
|
|
|
|
# use the patched dependencies to generate derivations for all the
|
|
# ruby dependencies (using a `gemset.nix` generated with bundix)
|
|
gems = bundlerEnv {
|
|
name = "wink-gems";
|
|
inherit ruby;
|
|
gemConfig = {
|
|
nokogiri = attrs: {
|
|
buildInputs = [ zlib ];
|
|
};
|
|
sqlite3 = attr: {
|
|
buildInputs = [ sqlite ];
|
|
};
|
|
};
|
|
gemfile = sources-patched.outPath + "/Gemfile";
|
|
lockfile = sources-patched.outPath + "/Gemfile.lock";
|
|
|
|
# Open question: we could generate this dynamically, would that be
|
|
# a good idea?
|
|
gemset = ./gemset.nix;
|
|
};
|
|
in
|
|
stdenv.mkDerivation {
|
|
name = "wink-without-wrapping";
|
|
|
|
src = sources-patched.outPath;
|
|
|
|
buildInputs = [
|
|
gems
|
|
ruby
|
|
makeWrapper
|
|
v8
|
|
];
|
|
|
|
# need to wrap the executables so ruby can find its gems
|
|
installPhase =
|
|
let gempath = "${gems.outPath}/lib/ruby/gems/2.6.0";
|
|
in ''
|
|
mkdir -p $out
|
|
cp -r * $out
|
|
|
|
makeWrapper $out/bin/rails $out/bin/rails-wrapped --set GEM_PATH ${gempath}
|
|
makeWrapper $out/bin/rake $out/bin/rake-wrapped --set GEM_PATH ${gempath}
|
|
'';
|
|
|
|
}
|