Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update configuration.nix #189

Merged
merged 6 commits into from
Jun 17, 2020

Conversation

nixbitcoin
Copy link
Member

This PR updates configuration.nix comments to the most current inter-option dependencies and introduces an assertions.nix to verify that all these dependencies are met.

Closes #37

@nixbitcoin nixbitcoin added this to In progress in nix-bitcoin via automation Jun 2, 2020
@erikarvstedt
Copy link
Collaborator

Awesome 🌟

  • trivial fixups
  • Remove assertion cfg.recurring-donations.enable -> cfg.clightning.enable, instead add services.clightning.enable = true to recurring-donations.nix.
    In general, service modules should enable services they depend on. Same for spark-wallet, webindex, nanopos, lightning-charge.
  • The remaining assertions should be defined directly in the relevant module files.
    • E.g., cfg.electrs.enable -> cfg.bitcoind.prune belongs to electrs.
    • cfg.lnd.enable -> !cfg.clightning.enable has no definite location, but we should move it to lnd.nix
  • The prune assertions for lnd and electrs fail when prune = null. I think it's best if we remove the possible null value for bitcoind.prune and set prune = 0 in bitcoind as a default. This is will make the assertions work. We can then also remove prune = 0 in secure-node.nix and the mkForce in configuration.nix (bitcoind.prune = lib.mkForce ).
  • Commit titles: Rename configuration: -> example config:

@nixbitcoin nixbitcoin added this to the Remove "experimental" from README.md milestone Jun 7, 2020
@nixbitcoin
Copy link
Member Author

I squashed your fixup, clarified nix-bitcoin will auto-detect invalid settings in all other comments as well, removed the possible null value for bitcoind.prune, and renamed the commits.

However, I don't think it's a good idea for service modules to enable services they depend on or to define assertions directly in the relevant module files.

  • Example1: What would happen if a user wanted to use lightning-charge with a different clightning module named clightning-with-plugins? Nix-bitcoin would try to enable clightning in the background and throw a confusing error.
  • Example 2: What would happen if a user tried to enable electrs outside nix-bitcoin with a custom bitcoind module that didn't even have a pruning option?

IMO this reduces modularity and should instead be handled in higher-level nix-bitcoin expressions like configuration.nix.

@erikarvstedt
Copy link
Collaborator

Great fixups, thanks!

I'm still convinced we should add the assertions to the corresponding modules (like in NixOS) as they are already tightly coupled:

  • Example1: lightning-charge is directly dependent on clightning via the reference to config.services.clightning.dataDir. It would already fail to be compatible with a hypothetic services.clightning-with-plugins.
  • Example 2: electrs is referencing the option config.services.bitcoind.dataDirReadableByGroup so it's already dependent on our nix-bitcoin specific bitcoind module.

You could indeed add the cfg.lnd.enable -> !cfg.clightning.enable assertion to modules.nix, because it belongs to more than one service module.

@nixbitcoin
Copy link
Member Author

Thanks for the explanation, I agree now on adding assertions to the modules. I'll work on implementing.

I still am not convinced it's a good idea to cross-enable modules without the users explicit direction. But I'm of course willing to reconsider. Any comment on this @jonasnick ?

@jonasnick
Copy link
Member

Imo allowing modules to be interchangeable is only very rarely useful. Instead of using a different clightning module it should be possible to make the existing clightning module more flexible. Moreover, having more logic in the modules themselves simplifies writing and maintaining them which I clearly noticed when @erikarvstedt added the option to set something like nix-bitcoin.secrets.bitcoin-rpcpassword directly in the module vs. the old way of defining all secrets in network.nix.

As for modules implicitly enabling other modules, I'd prefer to not do that to allow users to easily see and opt-in to what software they actually use on their node (for now at least... the number of modules is still manageable).

Remove the possible null value for bitcoind.prune and set prune = 0 in
bitcoind as a default. Remove prune = 0 in secure-node.nix and the
mkForce in configuration.nix (bitcoind.prune = lib.mkForce ).
HWI can be enabled if electrs is enabled as long as electrs.high-memory
is disabled.
@nixbitcoin
Copy link
Member Author

Moved assertions to individual modules and split them up into separate commits.

@erikarvstedt
Copy link
Collaborator

Fixups.
I've removed redundant antecedents in the assertion conditions and improved the assertion messages.
It's okay, even encouraged, to gather self-contained and related changes in a single commit, to ease reviewing.
assertions: add lnd, clightning exclusivity deserves its own commit because it contains two changes (hunks) in different files, where one change depends on the other.

@nixbitcoin
Copy link
Member Author

Just realized we need to ignore the lnd, clightning exclusivity assertion in order to run the tests, do you know how to do that?

@erikarvstedt
Copy link
Collaborator

I've added this to the fixups.

@nixbitcoin
Copy link
Member Author

Had to slightly correct your fixup and added a comment, explaining the ||

erikarvstedt
erikarvstedt previously approved these changes Jun 15, 2020
Copy link
Collaborator

@erikarvstedt erikarvstedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b9559ef

@nixbitcoin
Copy link
Member Author

Changed the HWI assertion to check disablewallet directly, as this is the speicifc option that makes it incompatible.

Copy link
Member

@jonasnick jonasnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK f280d54

@jonasnick jonasnick merged commit a03597a into fort-nix:master Jun 17, 2020
nix-bitcoin automation moved this from In progress to Done Jun 17, 2020
@nixbitcoin nixbitcoin deleted the update-configuration.nix branch March 3, 2021 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
nix-bitcoin
  
Done
Development

Successfully merging this pull request may close these issues.

Enable Pruning
3 participants