-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
bitbox-bridge: add systemd service and udev rule for linux distributions #391415
Conversation
d0ba5fd
to
f8093d7
Compare
@SuperSandro2000 @HeitorAugustoLN @ethancedwards8 @JohnRTitor This PR is ready for a review, afterwards I plan to create another PR where I'll add
Thus I appreciate if we could review/merge this PR as early as possible, at your convenience ;) |
@@ -34,6 +34,13 @@ rustPlatform.buildRustPackage (finalAttrs: { | |||
libudev-zero | |||
]; | |||
|
|||
postInstall = lib.optionals stdenv.hostPlatform.isLinux '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postInstall = lib.optionals stdenv.hostPlatform.isLinux '' | |
postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HeitorAugustoLN changes made, thanks for pointing it out! ;)
f8093d7
to
9ab4423
Compare
9ab4423
to
d5b0ef3
Compare
@@ -34,6 +34,13 @@ rustPlatform.buildRustPackage (finalAttrs: { | |||
libudev-zero | |||
]; | |||
|
|||
postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' | |||
mkdir -p $out/lib/systemd/user | |||
substitute ${./bitbox-bridge.service} $out/lib/systemd/user/bitbox-bridge.service \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installing systemd service manually is a bad idea. Please use the module system. systemd.user.services
suboptions should be what you are looking for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be is to use the upstream systemd service file and patch it during postPatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installing systemd service manually is a bad idea. Please use the module system. systemd.user.services suboptions should be what you are looking for.
I'm planning to do this as I mentioned in a separate PR. This PR adds this functionality for the ones who don't use NixOS
. What would be your specific solution for implementing this functionality with systemd.user.services
for people who don't use NixOS(archlinux with home-manager or MacOS etc.) How would that solution look like specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds this functionality for the ones who don't use
NixOS
I suppose you are right, but instead of having the same copy in two places, we can just copy the upstream one at install time, see below.
mkdir -p $out/lib/systemd/user | ||
substitute ${./bitbox-bridge.service} $out/lib/systemd/user/bitbox-bridge.service \ | ||
--subst-var-by bitbox-bridge $out/bin/bitbox-bridge | ||
install -Dt $out/lib/udev/rules.d ${./rules.d}/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
De we have to maintain the udev rules ourselves, on Nixpkgs? Does upstream not provide these in their repo?
EDIT: Looks like we can copy these from the src. https://github.com/BitBoxSwiss/bitbox-bridge/blob/63385207a0fb37f9bd7f0ff351214981a9b76d75/bitbox-bridge/release/linux/hid-digitalbitbox.rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure how to copy it from the src
in nix. What would be the specific reference in nix for the .rules
file here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps something like this?
And do it for both systemd and udev rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnRTitor done, thanks for the reference!
d5b0ef3
to
d20f551
Compare
postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' | ||
mkdir -p $out/lib/systemd/user | ||
substitute ${src}/bitbox-bridge/release/linux/bitbox-bridge.service $out/lib/systemd/user/bitbox-bridge.service \ | ||
--replace /opt/bitbox-bridge/bin/bitbox-bridge $out/bin/bitbox-bridge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--replace /opt/bitbox-bridge/bin/bitbox-bridge $out/bin/bitbox-bridge | |
--replace-fail /opt/bitbox-bridge/bin/bitbox-bridge $out/bin/bitbox-bridge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ;)
d20f551
to
f1c281e
Compare
substitute ${src}/bitbox-bridge/release/linux/bitbox-bridge.service $out/lib/systemd/user/bitbox-bridge.service \ | ||
--replace-fail /opt/bitbox-bridge/bin/bitbox-bridge $out/bin/bitbox-bridge | ||
install -Dm644 ${src}/bitbox-bridge/release/linux/hid-digitalbitbox.rules $out/lib/udev/rules.d/50-hid-digitalbitbox.rules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just this instead?
substitute ${src}/bitbox-bridge/release/linux/bitbox-bridge.service $out/lib/systemd/user/bitbox-bridge.service \ | |
--replace-fail /opt/bitbox-bridge/bin/bitbox-bridge $out/bin/bitbox-bridge | |
install -Dm644 ${src}/bitbox-bridge/release/linux/hid-digitalbitbox.rules $out/lib/udev/rules.d/50-hid-digitalbitbox.rules | |
substitute bitbox-bridge/release/linux/bitbox-bridge.service $out/lib/systemd/user/bitbox-bridge.service \ | |
--replace-fail /opt/bitbox-bridge/bin/bitbox-bridge $out/bin/bitbox-bridge | |
install -Dm644 bitbox-bridge/release/linux/hid-digitalbitbox.rules $out/lib/udev/rules.d/50-hid-digitalbitbox.rules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh ok I'll try this then we might be able to remove the rec as well
@@ -7,7 +7,7 @@ | |||
libudev-zero, | |||
}: | |||
|
|||
rustPlatform.buildRustPackage (finalAttrs: { | |||
rustPlatform.buildRustPackage (finalAttrs: rec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for rec
while using finalAttrs
rustPlatform.buildRustPackage (finalAttrs: rec { | |
rustPlatform.buildRustPackage (finalAttrs: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the rec is required for the src reference below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finalAttrs.src
does the same, and it is also not needed, you can operate on the $src
directly without needing to reference its derivation
f1c281e
to
da388d3
Compare
|
Things done
In the next PR(not this one), I plan to create nixos module to introduce
programs.bitbox-bridge.enable
andservices.bitbox-bridge.enable
with few options. These changes in this PR I suspect is needed for all linux distributions other thanNixOS
that allows users to installbitbox-bridge
vianix
orhome-manager
.Built on platform(s)
Tested basic functionality of all binary files (usually in
./result/bin/
)Fits CONTRIBUTING.md.