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

Service request: Signal DBus Service #62102

Open
matthew-piziak opened this issue May 26, 2019 · 13 comments
Open

Service request: Signal DBus Service #62102

matthew-piziak opened this issue May 26, 2019 · 13 comments
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@matthew-piziak
Copy link
Contributor

As described on the signal-cli Wiki.

signal-cli can run in daemon mode and provides an experimental dbus interface.

This specifically requires jni/unix-java.so, and requires a separate user and a configuration file.

The suggested manual process goes something like this:

cp data/org.asamk.Signal.conf /etc/dbus-1/system.d/
cp data/org.asamk.Signal.service /usr/share/dbus-1/system-services/
cp data/signal.service /etc/systemd/system/
sed -i -e "s|%dir%|<INSERT_INSTALL_PATH>|" -e "s|%number%|<INSERT_YOUR_NUMBER>|" /etc/systemd/system/signal.service
systemctl daemon-reload
systemctl enable signal.service
systemctl reload dbus.service

But it would be nice to have it packaged up as a Nix service.

@matthew-piziak
Copy link
Contributor Author

Emacs also has a DBus interface, so with DBus and LUI it should be quite easy to create a robust and performant chat client for Signal. I don't know well enough how to package services though, so I hope that someone can help me there.

@aanderse
Copy link
Member

@matthew-piziak Please go ahead and mention any specific issues you are having and we'll do our best to help.

@symbiont-matthew-piziak

Thanks @aanderse! Right now I have signal-cli on an idle loop inside my Emacs process and connected up to LUI. It serves my purposes well enough so I probably won't jump on this soon. At some point I may want the additional robustness though, in which case I'll refer back to this issue as I try to get the service running. :)

@matthew-piziak
Copy link
Contributor Author

In testing I got Missing native library dependency for dbus service: no unix-java in java.library.path.

How do I satisfy this dependency on NixOS?

@matthew-piziak
Copy link
Contributor Author

I have pkgs.libmatthew_java installed, but it's not on the Java path. Here is how to do it on Fedora: https://github.com/AsamK/signal-cli/wiki/Setup-on-fedora-26-with-dbus. But I don't know how to do it in NixOS.

@matthew-piziak
Copy link
Contributor Author

matthew-piziak commented Oct 27, 2019

I tried sudo ln -s /nix/store/c764v07frma64dnnwjniax7jmp0y54hb-libmatthew-java-0.8/lib/jni/libunix-java.so /usr/lib64/libunix-java.so as per this page but it didn't help.

Is there a way I can run the signal-cli executable where I add the nix path to the -Djava.library.path?

@matthew-piziak
Copy link
Contributor Author

matthew-piziak commented Oct 27, 2019

I tried adding libmatthew_java to signal-cli's PATH like so:

installPhase = ''
      mkdir -p $out/bin
      cp -r lib $out/lib
      cp bin/signal-cli $out/bin/signal-cli
      wrapProgram $out/bin/signal-cli \
      --prefix PATH : ${lib.makeBinPath [ pkgs.jre_headless pkgs.libmatthew_java ]} \
      --set JAVA_HOME ${pkgs.jre_headless}
    '';

But I get the same error when trying to run signal-cli as daemon. @aanderse do you have any idea of what I could be doing wrong?

@matthew-piziak
Copy link
Contributor Author

I tried the following derivation,

{ config, pkgs, lib, ... }:
let
  signal-cli = pkgs.signal-cli.overrideAttrs (attrs: {
    buildInputs = with pkgs; [ makeWrapper libmatthew_java ];
    installPhase = ''
      mkdir -p $out/bin
      cp -r lib $out/lib
      cp bin/signal-cli $out/bin/signal-cli
      export JAVA_OPTS='-Djava.library.path ${lib.makeBinPath [ pkgs.libmatthew_java ]}'
      wrapProgram $out/bin/signal-cli \
        --prefix PATH : ${lib.makeBinPath [ pkgs.jre_headless ]} \
        --set JAVA_HOME ${pkgs.jre_headless}
    '';
  });
in {
  environment.systemPackages = [ signal-cli ]
    ++ (with pkgs; [ qrencode shared-mime-info signal-desktop ]);
}

…but it fails with

Error: Could not find or load main class .nix.store.h763fyxacqas0xc40b1i08dxq0dy9c07-libmatthew-java-0.8.bin

@matthew-piziak
Copy link
Contributor Author

I've broken out the specific signal-cli daemon bug into a separate issue: #72737

@stale
Copy link

stale bot commented Jun 1, 2020

Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the
    related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on
    irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 1, 2020
@kcghost
Copy link

kcghost commented Aug 26, 2021

This is important to me!

It would be nice if this functionality worked out of the box. I'm not certain how to manually start the daemon either. There might be a new issue since this was last discussed? I get the following error:

signal-cli -u +(phone_number) daemon
ERROR DaemonCommand - Dbus command failed
org.freedesktop.dbus.exceptions.DBusException: Failed to connect to bus: Failed to auth
	at org.freedesktop.dbus.connections.AbstractConnection.<init>(AbstractConnection.java:166)
	at org.freedesktop.dbus.connections.impl.DBusConnection.<init>(DBusConnection.java:334)
	at org.freedesktop.dbus.connections.impl.DBusConnection.getConnection(DBusConnection.java:149)
	at org.freedesktop.dbus.connections.impl.DBusConnection.getConnection(DBusConnection.java:169)
	at org.freedesktop.dbus.connections.impl.DBusConnection.getConnection(DBusConnection.java:228)
	at org.freedesktop.dbus.connections.impl.DBusConnection.getConnection(DBusConnection.java:184)
	at org.asamk.signal.commands.DaemonCommand.handleCommand(DaemonCommand.java:66)
	at org.asamk.signal.App.handleLocalCommand(App.java:204)
	at org.asamk.signal.App.init(App.java:164)
	at org.asamk.signal.Main.main(Main.java:49)
Caused by: java.io.IOException: Failed to auth
	at org.freedesktop.dbus.connections.transports.AbstractTransport.authenticate(AbstractTransport.java:114)
	at org.freedesktop.dbus.connections.transports.UnixSocketTransport.connect(UnixSocketTransport.java:69)
	at org.freedesktop.dbus.connections.transports.TransportFactory.createTransport(TransportFactory.java:44)
	at org.freedesktop.dbus.connections.AbstractConnection.<init>(AbstractConnection.java:161)
	... 9 more
Dbus command failed

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 26, 2021
@matthew-piziak
Copy link
Contributor Author

@kcghost I went back to using non-daemon commands on a loop because of that issue. Tracking here: AsamK/signal-cli#315

@matthew-piziak
Copy link
Contributor Author

matthew-piziak commented Nov 23, 2021

Reproduced on signal-cli 0.9.2

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

No branches or pull requests

4 participants