Open hkjn opened 5 years ago
In this case, optional dependencies like
tor-browser-bundle-bin
would be better listed as dependencies of the package rather than being downloaded dynamically by the application.
The reason its downloaded dynamically is to avoid the extra 200MB+ for users who aren't going to be using onion...
Perhaps the NixOS packaging process could run npm install
inside the src/transport/granax-dep
directory to have the tor binaries as part of the package? (I'm not too familiar with NixOS, not sure how this works there)
binaries or libraries it needs are on
$PATH
and make use of them
Setting GRANAX_USE_SYSTEM_TOR=1
as an env variable (or --granax-use-system-tor 1
as an argument) should do the trick, but I haven't had the chance to try that. Can you try and report if that works?
Perhaps the NixOS packaging process could run
npm install
inside thesrc/transport/granax-dep
directory to have the tor binaries as part of the package? (I'm not too familiar with NixOS, not sure how this works there)
There should be a way to specify that tor package is a dependency for the spark-wallet package on Nix. (Or optionally that a separate spark-wallet-full package or similar provides Tor, if the weight of the dependency makes it desirable to offer a package without it as well).
I'm not super familiar with Nix yet either, but it looks like the nix-bitcoin project defines a list of node packages created by the node2nix tool, so perhaps the correct way to improve this is to modify the package definition over in nix-bitcoin:
I can continue looking at that and open an issue over in their repo if necessary, since they are the ones maintaining the Nix package for spark-wallet.
Setting GRANAX_USE_SYSTEM_TOR=1 as an env variable (or --granax-use-system-tor 1 as an argument) should do the trick, but I haven't had the chance to try that. Can you try and report if that works?
I tried both methods, but it still seems that spark-wallet is attempting to fetch Tor:
$ spark-wallet --granax-use-system-tor 1 --no-rates --onion
Connected to c-lightning v0.7.1 with id 03a9c46ddacd373f78b6679f9dec6adb10b3dc78ca1602a685e09b2ce6101bc18c on network bitcoin at /home/user/.lightning/lightning-rpc
Loading login credentials from /home/user/.spark-wallet/cookie
Tor Hidden Service enabled (via --onion) for the first time, downloading the Tor Bundle...
[...]
npm WARN checkPermissions Missing write access to /nix/store/xrpqwni739bs8c1qphal5593sc6vf7ca-node-spark-wallet-0.2.8/lib/node_modules/spark-wallet/dist/transport/granax-dep
npm ERR! path /nix/store/xrpqwni739bs8c1qphal5593sc6vf7ca-node-spark-wallet-0.2.8/lib/node_modules/spark-wallet/dist/transport/granax-dep
npm ERR! code EACCES
[...]
$ GRANAX_USE_SYSTEM_TOR=1 spark-wallet --no-rates --onion
Connected to c-lightning v0.7.1 with id 03a9c46ddacd373f78b6679f9dec6adb10b3dc78ca1602a685e09b2ce6101bc18c on network bitcoin at /home/user/.lightning/lightning-rpc
Loading login credentials from /home/user/.spark-wallet/cookie
Tor Hidden Service enabled (via --onion) for the first time, downloading the Tor Bundle...
[...]
npm WARN checkPermissions Missing write access to /nix/store/xrpqwni739bs8c1qphal5593sc6vf7ca-node-spark-wallet-0.2.8/lib/node_modules/spark-wallet/dist/transport/granax-dep
npm ERR! path /nix/store/xrpqwni739bs8c1qphal5593sc6vf7ca-node-spark-wallet-0.2.8/lib/node_modules/spark-wallet/dist/transport/granax-dep
Using the Nix package of spark-wallet from https://github.com/fort-nix/nix-bitcoin causes a crash with v0.2.8 on NixOS (and possibly other distros), due to the app not having write permissions to a local directory where it tries to download Tor:
(Mangled output in original as well.)
On NixOS, install paths for packages are read-only, so any changes to disk would need to happen in a mutable data directory. In this case, optional dependencies like
tor-browser-bundle-bin
would be better listed as dependencies of the package rather than being downloaded dynamically by the application.In my case, I in fact already have the
tor
as well astor-browser-bundle-bin
packages installed on my system, so ideally spark-wallet would detect that the binaries or libraries it needs are on$PATH
and make use of them in this situation.