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

nixos/bitcoind: add bitcoind service #50618

Merged
merged 1 commit into from May 22, 2019
Merged

Conversation

dongcarl
Copy link
Contributor

Motivation for this change

Easily run bitcoind.

Things done

@dongcarl dongcarl force-pushed the service-bitcoind branch 3 times, most recently from c7b2fc9 to d8de551 Compare November 18, 2018 19:24
@dongcarl dongcarl changed the title nixos/bitocind: add bitcoind service nixos/bitcoind: add bitcoind service Nov 18, 2018
nixos/modules/misc/ids.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
@dongcarl dongcarl force-pushed the service-bitcoind branch 2 times, most recently from 6d47266 to 5ad69f3 Compare November 20, 2018 04:14
@jonasnick
Copy link
Contributor

An rpcpassword option would be nice because it's more common than rpcauth.

nixos/modules/misc/ids.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
@dongcarl
Copy link
Contributor Author

An rpcpassword option would be nice because it's more common than rpcauth.

@jonasnick I deliberately omitted that because that would have the plaintext password in the config file, whereas rpcauth is the HMAC-SHA-256.

@jb55
Copy link
Contributor

jb55 commented Dec 7, 2018

once this is merged I'll open up a PR that implements multiple networks here: jb55@871b456 I'm currently using this to run both mainnet and testnet.

@Mic92
Copy link
Member

Mic92 commented May 8, 2019

What was the status of this? I have not looked into it for a while.

@dongcarl
Copy link
Contributor Author

dongcarl commented May 8, 2019

What was the status of this? I have not looked into it for a while.

I'll update this in the next few weeks, feel free to submit patches to make my life easier 😁

@jb55
Copy link
Contributor

jb55 commented May 8, 2019

fwiw I've been using this in production since this PR was opened + a few patches I've added to add multi-network which I plan to PR once this is merged.

@dongcarl
Copy link
Contributor Author

Addressed all comments except: #50618 (comment). Please advise.

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

Things yet to address:

#50618 (comment) , In particular you shouldn't need a static uid/gid at all, see #60732 (comment).

Using literalExample, https://github.com/NixOS/nixpkgs/pull/50618/files#r284444067

Adding a configFile option, #50618 (comment)

nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
@dongcarl
Copy link
Contributor Author

@infinisil Thanks for your review!

This shouldn't be needed if the service doesn't fork?

Done!

#50618 (comment) , In particular you shouldn't need a static uid/gid at all, see #60732 (comment).

Ended up not setting a uid/gid, which makes them null and NixOS will pick one for me (neat!).

Using literalExample, NixOS/nixpkgs/pull/50618/files#r284444067

Done!

Adding a configFile option, #50618 (comment)

Done!

StateDirectory should only do something for dataDir = "/var/lib/bitcoind", so you should either turn this off completely and handle permissions yourself for arbitrary dataDir (via systemd.tmpfiles preferably instead of this preStart script), or alternatively, don't provide a dataDir option at all, and make it not configurable, then it makes sense to use StateDirectory (without setting permissions in preStart either).

Ended up removing StateDirectory completely. Bitcoin's datadir is 200GB+, so I want to make it configurable in case people want to mount their larger disk somewhere else. systemd.tmpfiles wouldn't work as we need it to persist across node restarts.

@infinisil
Copy link
Member

systemd.tmpfiles wouldn't work as we need it to persist across node restarts.

It's a bit of a misnomer, but that option can in fact be used for non-temporary files/directories as well, and that is in fact the most common usage for it in NixOS.

@dongcarl
Copy link
Contributor Author

dongcarl commented May 22, 2019

@infinisil

systemd.tmpfiles wouldn't work as we need it to persist across node restarts.

It's a bit of a misnomer, but that option can in fact be used for non-temporary files/directories as well, and that is in fact the most common usage for it in NixOS.

Ah okay, I think we'll stick with this for simplicity for now, perhaps someone else can PR the systemd.tmpfiles support later 😄

Let me know if I'm missing anything else!

@infinisil
Copy link
Member

There is already an effort for removing such permission scripts in favor of systemd.tmpfiles by @aanderse in #56265, so I'd rather have that in this PR as well. systemd.tmpfiles is very much in the spirit of NixOS in that it's declarative and not stateful. Look at the changes in that PR to see how permission scripts translate to systemd.tmpfiles (or read man tmpfiles.d).

@dongcarl
Copy link
Contributor Author

Updated to use systemd.tmpfiles.

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

One more minor round

nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
nixos/modules/services/networking/bitcoind.nix Outdated Show resolved Hide resolved
@dongcarl
Copy link
Contributor Author

@infinisil Done! Thank you for your patience!

@infinisil infinisil merged commit 7d25022 into NixOS:master May 22, 2019
@infinisil
Copy link
Member

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants