After lots of experimentation I have landed on this as my proposal for how we have our Go binary find its Ruby counterpart: just have it grab it from the $PATH! @evanphx showed me this neat trick where by borrowing a couple of helper methods from `exec` and tweaking them we can get logic that will do a $PATH lookup that excludes "ourself". This allows us to have both `vagrant` executables on the path... and means that switching between Gogo-by-default or Legacy-by-default is just a matter of tweaking $PATH order. It _also_ means that we don't need any different lookup logic for "release mode" vs "development mode" which is what I was looking at before this solution. In order to continue to facilitate development, I've generated a binstub for vagrant using `bundle binstubs vagrant --standalone --path ./binstubs`, and I've updated the Nix development setup to prepend this directory to the $PATH. NOTE: Non-Nix users will need to modify their $PATH in the same way to get the same behavior in development.
74 lines
1.1 KiB
Nix
74 lines
1.1 KiB
Nix
{ lib
|
|
, stdenv
|
|
, autoconf
|
|
, autogen
|
|
, automake
|
|
, go
|
|
, go-bindata
|
|
, go-changelog
|
|
, go-mockery
|
|
, go-protobuf
|
|
, go-protobuf-json
|
|
, go-tools
|
|
, grpc-tools
|
|
, grpcurl
|
|
, libarchive
|
|
, libpng
|
|
, libtool
|
|
, mkShell
|
|
, nasm
|
|
, nodejs-16_x
|
|
, pkg-config
|
|
, protobufPin
|
|
, protoc-gen-doc
|
|
, protoc-gen-go-grpc
|
|
, ruby
|
|
, zlib
|
|
}:
|
|
|
|
mkShell rec {
|
|
name = "vagrant";
|
|
|
|
packages = [
|
|
go
|
|
go-bindata
|
|
grpcurl
|
|
nodejs-16_x
|
|
protoc-gen-doc
|
|
ruby
|
|
|
|
# Need bsdtar to run ruby tests
|
|
libarchive
|
|
|
|
# Custom packages, added to overlay
|
|
protobufPin
|
|
protoc-gen-go-grpc
|
|
go-protobuf
|
|
go-protobuf-json
|
|
go-tools
|
|
go-mockery
|
|
go-changelog
|
|
grpc-tools
|
|
|
|
# Needed for website/
|
|
autoconf
|
|
autogen
|
|
automake
|
|
libpng
|
|
libtool
|
|
nasm
|
|
pkg-config
|
|
zlib
|
|
];
|
|
|
|
shellHook = ''
|
|
# workaround for npm/gulp dep compilation
|
|
# https://github.com/imagemin/optipng-bin/issues/108
|
|
LD=$CC
|
|
|
|
# Prepend binstubs to PATH for development, which causes Vagrant-agogo
|
|
# to use the legacy Vagrant in this repo. See client.initVagrantRubyRuntime
|
|
PATH=$PWD/binstubs:$PATH
|
|
'';
|
|
}
|