mlabs-haskell / cardano.nix

Nix ❤️ Cardano
https://mlabs-haskell.github.io/cardano.nix/
1 stars 0 forks source link

Cardano-db-sync module #59

Closed zmrocze closed 1 month ago

zmrocze commented 2 months ago

solves issue #58.

Cardano-db-sync module. With cardano-db-sync.postgres.enable also runs postgres. Single test that awaits sync progress to start.

zmrocze commented 2 months ago

eh, attic input fails to build with these nixpkgs. but still id say go ahead and review

zmrocze commented 2 months ago

our nixos tests run forever in CI. Locally it's maybe 25 secs for me. But previously the db-sync failed after reaching 100s timeout (which it reached after many minutes (?))

zmrocze commented 1 month ago

@brainrake i think it's fine now, would you check once more? I simply removed the marked redundant options and the redundent postgres authentication setting (relic of some fix while experimenting).

Irrelevant note on the side:

Before I was under the impression that you're supposed to abstract away the underlying module (here services.cardano-db-sync) with your module (cardano.db-sync) - and make the user not touch the underlying module. I see it's differently with nixos modules, but it does make some sense, I mean it's more direct and doesn't repeat and in the end the module abstraction is always going to be leaky. On the downside the user needs to not only read the option docs but also the source including imports.

brainrake commented 1 month ago

Thanks @zmrocze , that makes sense. I think you solved one part by mentoning services.cardano-db-sync in the cardano.db.sync.enable documentation. We can make it more explicit, or add a link. Another part is rendering the documentation for the services.* modules: https://github.com/mlabs-haskell/cardano.nix/pull/71 .

Let me explain. There were upstream modules for cardano-node and cardano-db-sync. Wrapping everything leads to a large amount of extra code with no apparent advantage except having all the options in the same namespace. So we went the opposite way, not wrapping anything, just adding the minimum options to support default use cases (sometimes just enable), and setting options to coordinate between modules. You can set up the default use cases with the very few options under cardano.*. If you need more configurability, you can use the modules. Another advantage is that modules under services.* without any dependencies by just importing the file. They can be easily contributed upstream or to nixpkgs.