Skip to content

Commit

Permalink
missing vendorHash update, documented the process on how to update it
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtajti committed Oct 10, 2023
1 parent 33a35a0 commit 0afa173
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ There are a few things that don't currently work in `redis-oplog` when using the
- Custom namespaces and channels ([`redis-oplog` issue #279](https://github.com/cult-of-coders/redis-oplog/issues/279))
- Synthetic mutations ([`redis-oplog` issue #277](https://github.com/cult-of-coders/redis-oplog/issues/277))

## Nix

We are using Nix at Tulip so we're rolling a `default.nix` and a `flake.nix` wrapper around it for Flake support. The `default.nix` file contains a `vendorHash` attribute, which would be the calculated hash of the downloaded modules to be vendored. To update this value after a `go.sum` file change (which means that different modules were downloaded), refer to the following snippet:

```bash
# TODO: default.nix: Change the `vendorHash` property to an empty string and run `nix build`.
nix build
# ...
# error: hash mismatch in fixed-output derivation '/nix/store/by8bc99ywfw6j1i6zjxcwdmc5b3mmgzv-oplogtoredis-3.0.0-go-modules.drv':
# specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
# got: sha256-ceToA2DC1bhmg9WIeNSAfoNoU7sk9PrQqgqt5UbpivQ=
```

### MongoDB v5

MongoDB v5 makes a substantial change to the format of the oplog, which makes it much more difficult to assemble the list of changed fields from an oplog entry. Meteor has handled this with a full [oplog v2 to v1 converter](https://github.com/meteor/meteor/blob/devel/packages/mongo/oplog_v2_converter.js), which entails substantial complexity and a high level of dependence on the (undocumented) oplog format, and requires testing against every new version of Mongo. To reduce this maintenance burden, oplogtoredis implements a simplified version of this algorithm that just extracts changed top-level fields.
Expand Down
15 changes: 13 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
{ lib, stdenv, buildGoModule, fetchFromGitHub, installShellFiles }:

buildGoModule {
pname = "oplogtoredis";
version = "3.0.0";

src = builtins.path { path = ./.; };

vendorSha256 = "sha256-VHiYVJUNtHN2IY4iXZ6kHAa3Avi2VwRH1ySKBrrCDu4=";
postInstall = ''
'';

# update: set value to an empty string and run `nix build`. This will download Go, fetch the dependencies and calculates their hash.
vendorHash = "sha256-ceToA2DC1bhmg9WIeNSAfoNoU7sk9PrQqgqt5UbpivQ=";

nativeBuildInputs = [ installShellFiles ];
doCheck = false;
doInstallCheck = false;

meta = with lib; {
description = ''
This program tails the oplog of a Mongo server, and publishes changes to Redis.
It's designed to work with the redis-oplog Meteor package'';
homepage = "https://github.com/tulip/oplogtoredis";
license = licenses.mit;
};
}
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0afa173

Please sign in to comment.