summary refs log tree commit diff
path: root/pkgs/tools/security/tor/default.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2020-12-31 07:31:38 +0100
committerJörg Thalheim <joerg@thalheim.io>2020-12-31 07:31:38 +0100
commitf19b7b03a03b7f1d5beb44471eb9298de4b9e186 (patch)
tree2bb5fabe03cff0c2058f69921315ab3ff724f9d0 /pkgs/tools/security/tor/default.nix
parent572a864d024b0c91ac39133f35364362b2376c07 (diff)
parent7a580a12196e63eb665de6eb4db8bb3b6da142f5 (diff)
downloadnixpkgs-f19b7b03a03b7f1d5beb44471eb9298de4b9e186.tar
nixpkgs-f19b7b03a03b7f1d5beb44471eb9298de4b9e186.tar.gz
nixpkgs-f19b7b03a03b7f1d5beb44471eb9298de4b9e186.tar.bz2
nixpkgs-f19b7b03a03b7f1d5beb44471eb9298de4b9e186.tar.lz
nixpkgs-f19b7b03a03b7f1d5beb44471eb9298de4b9e186.tar.xz
nixpkgs-f19b7b03a03b7f1d5beb44471eb9298de4b9e186.tar.zst
nixpkgs-f19b7b03a03b7f1d5beb44471eb9298de4b9e186.zip
Merge branch 'master' into staging-next
Diffstat (limited to 'pkgs/tools/security/tor/default.nix')
-rw-r--r--pkgs/tools/security/tor/default.nix18
1 files changed, 17 insertions, 1 deletions
diff --git a/pkgs/tools/security/tor/default.nix b/pkgs/tools/security/tor/default.nix
index 04bf598d132..e46fd4790a3 100644
--- a/pkgs/tools/security/tor/default.nix
+++ b/pkgs/tools/security/tor/default.nix
@@ -1,5 +1,6 @@
 { stdenv, fetchurl, pkgconfig, libevent, openssl, zlib, torsocks
 , libseccomp, systemd, libcap, lzma, zstd, scrypt, nixosTests
+, writeShellScript
 
 # for update.nix
 , writeScript
@@ -12,7 +13,21 @@
 , gnused
 , nix
 }:
-
+let
+  tor-client-auth-gen = writeShellScript "tor-client-auth-gen" ''
+    PATH="${stdenv.lib.makeBinPath [coreutils gnugrep openssl]}"
+    pem="$(openssl genpkey -algorithm x25519)"
+
+    printf private_key=descriptor:x25519:
+    echo "$pem" | grep -v " PRIVATE KEY" |
+    base64 -d | tail --bytes=32 | base32 | tr -d =
+
+    printf public_key=descriptor:x25519:
+    echo "$pem" | openssl pkey -in /dev/stdin -pubout |
+    grep -v " PUBLIC KEY" |
+    base64 -d | tail --bytes=32 | base32 | tr -d =
+  '';
+in
 stdenv.mkDerivation rec {
   pname = "tor";
   version = "0.4.4.6";
@@ -52,6 +67,7 @@ stdenv.mkDerivation rec {
     mkdir -p $geoip/share/tor
     mv $out/share/tor/geoip{,6} $geoip/share/tor
     rm -rf $out/share/tor
+    ln -s ${tor-client-auth-gen} $out/bin/tor-client-auth-gen
   '';
 
   passthru = {