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/bitbox-bridge: init #392817

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

izelnakri
Copy link
Contributor

@izelnakri izelnakri commented Mar 24, 2025

This PR adds config.services.bitbox-bridge to NixOS.

Previous PR could be found here: #391415

Things done

  • Adds the most basic service configuration for config.services.bitbox-bridge.

  • Adds a nix test to check bitbox-bridge can be built & run.

  • Adds config.services.bitbox-bridge.runOnMount to run the systemd service only on mount. It does proper systemd device unit registration when hardware wallet is plugged via udev.

  • Built on platform(s)

    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested basic functionality of all binary files (usually in ./result/bin/)

  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Mar 24, 2025
@izelnakri izelnakri force-pushed the package-bitbox-bridge branch 3 times, most recently from 8a1a31f to 370ced5 Compare March 26, 2025 01:29
@nix-owners nix-owners bot requested a review from tensor5 March 26, 2025 01:36
@izelnakri izelnakri force-pushed the package-bitbox-bridge branch 2 times, most recently from 0143e4c to 4b24603 Compare March 27, 2025 07:27
@izelnakri
Copy link
Contributor Author

izelnakri commented Mar 27, 2025

@JohnRTitor @HeitorAugustoLN @ethancedwards8 @SuperSandro2000 This PR is ready for review.

I've specifically also manually tested services.bitbox-bridge.runOnMount feature on all possible cases. Let me know if there is anything else I should do ;)

runOnMount = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enable running bitbox-bridge.service only when hardware wallet is plugged, also registers the systemd device unit. When false, bitbox-bridge service runs all the time.
'';
};
Copy link
Member

@HeitorAugustoLN HeitorAugustoLN Mar 27, 2025

Choose a reason for hiding this comment

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

Suggested change
runOnMount = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enable running bitbox-bridge.service only when hardware wallet is plugged, also registers the systemd device unit. When false, bitbox-bridge service runs all the time.
'';
};
runOnMount = lib.mkEnableOption ''
running bitbox-bridge.service only when hardware wallet is plugged, also registers the systemd device unit.
When false, bitbox-bridge service runs all the time'';

Copy link
Contributor Author

@izelnakri izelnakri Mar 27, 2025

Choose a reason for hiding this comment

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

I've changed the logic to make services.bitbox-bridge.runOnMount = true by default, seems like a better default to conserve power/battery. Let me know if you still think we should change it ;)

@izelnakri izelnakri force-pushed the package-bitbox-bridge branch from 4b24603 to 7bdef6d Compare March 27, 2025 14:29
@izelnakri izelnakri force-pushed the package-bitbox-bridge branch from 7bdef6d to 6b7ba8b Compare March 27, 2025 16:06
Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

Rest LGTM:

Commit messages need updating though:

  1. nixosTests/bitbox-bridge: init
  2. This isn't really needed, AFAIK services.udev.package will still pickup the rules from lib fine. But don't just take my word for it, you can verify the path yourself.
  3. nixos/bitbox-bridge: init
  4. Can be merged with the above commit

Comment on lines 25 to 31
runOnMount = lib.mkOption {
type = lib.types.bool;
default = true;
example = false;
description = ''
Run bitbox-bridge.service only when hardware wallet is plugged, also registers the systemd device unit.
This option is enabled by default to save power, when false, bitbox-bridge service runs all the time instead.
'';;
};
Copy link
Contributor

@JohnRTitor JohnRTitor Mar 27, 2025

Choose a reason for hiding this comment

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

I was typing a review comment for this, exactly when you updated :)

So as you can see using mkEnableOption auto appends stuff:

Whether to enable Run bitbox-bridge.service only.....

You want something like this instead:

Suggested change
runOnMount = lib.mkOption {
type = lib.types.bool;
default = true;
example = false;
description = ''
Run bitbox-bridge.service only when hardware wallet is plugged, also registers the systemd device unit.
This option is enabled by default to save power, when false, bitbox-bridge service runs all the time instead.
'';;
};
runOnMount = lib.mkEnableOption null // {
default = true;
description = ''
Run bitbox-bridge.service only when hardware wallet is plugged, also registers the systemd device unit.
This option is enabled by default to save power, when false, bitbox-bridge service runs all the time instead.
'';
};

You can check how it looks by downloading the artifact from our CI NixOS manal build then looking at the options.html.

Or you can build the manual yourself:

nix build --print-out-paths ".#htmlDocs.nixosManual.x86_64-linux"

Copy link
Contributor Author

@izelnakri izelnakri Mar 27, 2025

Choose a reason for hiding this comment

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

I've changed the logic to make services.bitbox-bridge.runOnMount = true by default, seems like a better default to conserve power/battery. Let me know if you still think we should change it ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Please use mkEnableOption. You can still enable it by default by setting the override, just like how I did.

@izelnakri izelnakri force-pushed the package-bitbox-bridge branch 5 times, most recently from 17aa843 to 056970d Compare March 27, 2025 16:58
@izelnakri
Copy link
Contributor Author

izelnakri commented Mar 27, 2025

@HeitorAugustoLN @JohnRTitor requested changes are done.

This isn't really needed, AFAIK services.udev.package will still pickup the rules from lib fine. But don't just take my word for it, you can verify the path yourself.

@JohnRTitor I've specifically made this change after testing it on my NixOS machine and another archlinux machine that runs with nix. The other way created some issues as far as I remember. Please let me know below any other changes needed. Thanks! ;)

@JohnRTitor
Copy link
Contributor

after testing it on my NixOS machine and another archlinux machine that runs with nix

Right. NixOS module system knows that we should install udev rules to /etc when installing the system, whereas Nix package manager on other distros may just install the rules to existing /lib if we don't explicitly tell it to.

@izelnakri
Copy link
Contributor Author

izelnakri commented Mar 27, 2025

after testing it on my NixOS machine and another archlinux machine that runs with nix

Right. NixOS module system knows that we should install udev rules to /etc when installing the system, whereas Nix package manager on other distros may just install the rules to existing /lib if we don't explicitly tell it to.

@JohnRTitor Yes I think I couldn't also get it working in NixOS because the /lib udev rules don't get copied to /etc/udev and applied as rules. So instead of duplicating the logic I decided to move it to /etc. I think this approach is good enough, let me know if you'd like a different specific solution and I'll do it. I'd like this PR to be approved & merged, after all ;)

Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

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

Just add a release note and we are good.

@JohnRTitor JohnRTitor changed the title bitbox-bridge: Add config.services.bitbox-bridge nixos/bitbox-bridge: init Mar 28, 2025
@izelnakri izelnakri force-pushed the package-bitbox-bridge branch from 5f50221 to bfe4696 Compare March 28, 2025 04:53
@github-actions github-actions bot added 8.has: changelog 8.has: documentation This PR adds or changes documentation labels Mar 28, 2025
@izelnakri
Copy link
Contributor Author

Just add a release note and we are good.

Not sure if I added to the right release note(s), but I guess its done now! :) 🎉

@h7x4 h7x4 added 8.has: module (new) This PR adds a module in `nixos/` 8.has: tests This PR has tests labels Mar 28, 2025
Signed-off-by: John Titor <50095635+JohnRTitor@users.noreply.github.com>
@JohnRTitor JohnRTitor force-pushed the package-bitbox-bridge branch from bfe4696 to 2aeb633 Compare March 28, 2025 17:12
@JohnRTitor
Copy link
Contributor

LGTM, but looks like I forgot to tell you to add nixosTests.bitbox-bridge to the package's passthru.tests.

I'll do it myself and then merge.

nixos tests and nix-update-script added

Signed-off-by: John Titor <50095635+JohnRTitor@users.noreply.github.com>
@JohnRTitor
Copy link
Contributor

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 392817

Logs: https://github.com/JohnRTitor/nixpkgs-review-gha/actions/runs/14134406559


x86_64-linux

✅ 2 packages built:
  • bitbox-bridge
  • bitbox-bridge.passthru.tests.basic

aarch64-linux

❌ 1 package failed to build:
  • bitbox-bridge.passthru.tests.basic
✅ 1 package built:
  • bitbox-bridge

x86_64-darwin

❌ 1 package failed to build:
  • bitbox-bridge.passthru.tests.basic
✅ 1 package built:
  • bitbox-bridge

aarch64-darwin

❌ 1 package failed to build:
  • bitbox-bridge.passthru.tests.basic
✅ 1 package built:
  • bitbox-bridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (new) This PR adds a module in `nixos/` 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: tests This PR has tests 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants