From 15e8c2a2f2d222a50c23f9fdfcea5ca27637bba1 Mon Sep 17 00:00:00 2001 From: Amadej Kastelic Date: Thu, 17 Jul 2025 20:12:38 +0200 Subject: [PATCH 1/6] cjdns: 21.4 -> 22.1 --- pkgs/by-name/cj/cjdns/package.nix | 40 +++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/cj/cjdns/package.nix b/pkgs/by-name/cj/cjdns/package.nix index e095b3f3b35f..5c90ca7b4714 100644 --- a/pkgs/by-name/cj/cjdns/package.nix +++ b/pkgs/by-name/cj/cjdns/package.nix @@ -2,11 +2,10 @@ lib, stdenv, fetchFromGitHub, + fetchpatch, rustPlatform, nodejs, which, - python3, - libuv, util-linux, nixosTests, libsodium, @@ -16,26 +15,34 @@ rustPlatform.buildRustPackage rec { pname = "cjdns"; - version = "21.4"; + version = "22.1"; src = fetchFromGitHub { owner = "cjdelisle"; repo = "cjdns"; - rev = "cjdns-v${version}"; - sha256 = "sha256-vI3uHZwmbFqxGasKqgCl0PLEEO8RNEhwkn5ZA8K7bxU="; + tag = "cjdns-v${version}"; + hash = "sha256-0imQrkcvIA+2Eq/zlC65USMR7T3OUKwQxrB1KtVexyU="; }; patches = [ (replaceVars ./system-libsodium.patch { libsodium_include_dir = "${libsodium.dev}/include"; }) + # Remove mkpasswd since it is failing the build + (fetchpatch { + url = "https://github.com/cjdelisle/cjdns/commit/6391dba3f5fdab45df4b4b6b71dbe9620286ce32.patch"; + hash = "sha256-XVA4tdTVMLrV6zuGoBCkOgQq6NXh0x7u8HgmaxFeoRI="; + }) + (fetchpatch { + url = "https://github.com/cjdelisle/cjdns/commit/436d9a9784bae85734992c2561c778fbd2f5ac32.patch"; + hash = "sha256-THcYNGVbMx/xf3/5UIxEhz3OlODE0qiYgDBOlHunhj8="; + }) ]; - cargoHash = "sha256-LJEKjhyAsK6b7mKObX8tNJdKt53iagMD/YLzoY5GVPw="; + cargoHash = "sha256-f96y6ZW0HxC+73ts5re8GIo2aigQgK3gXyF7fMrcJ0o="; nativeBuildInputs = [ which - python3 nodejs pkg-config ] @@ -43,10 +50,7 @@ rustPlatform.buildRustPackage rec { # for flock lib.optional stdenv.hostPlatform.isLinux util-linux; - buildInputs = [ - libuv - libsodium - ]; + buildInputs = [ libsodium ]; env.SODIUM_USE_PKG_CONFIG = 1; env.NIX_CFLAGS_COMPILE = toString ( @@ -61,10 +65,22 @@ rustPlatform.buildRustPackage rec { ] ); + cargoTestFlags = [ + # don't run doctests since they fail with "cannot find type `Ctx` in this scope" + "--lib" + "--bins" + "--tests" + ]; + + checkFlags = [ + # Tests don't seem to work - "called `Result::unwrap()` on an `Err` value: DecryptErr: NO_SESSION" + "--skip=crypto::crypto_auth::tests::test_wireguard_iface_encrypt_decrypt" + "--skip=crypto::crypto_auth::tests::test_wireguard_iface_encrypt_decrypt_with_auth" + ]; + passthru.tests.basic = nixosTests.cjdns; meta = with lib; { - broken = true; # outdated, incompatible with supported python versions homepage = "https://github.com/cjdelisle/cjdns"; description = "Encrypted networking for regular people"; license = licenses.gpl3Plus; From 7476494b3b16a4861035ef4a876d47050b7f1505 Mon Sep 17 00:00:00 2001 From: Amadej Kastelic Date: Sun, 27 Jul 2025 13:35:51 +0200 Subject: [PATCH 2/6] nixos/cjdns: update for cjdns 22.1 compatibility --- nixos/modules/services/networking/cjdns.nix | 4 ++-- nixos/tests/cjdns.nix | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/networking/cjdns.nix b/nixos/modules/services/networking/cjdns.nix index 1b9f53c9b28a..43ea76d5d710 100644 --- a/nixos/modules/services/networking/cjdns.nix +++ b/nixos/modules/services/networking/cjdns.nix @@ -49,7 +49,7 @@ let k: v: lib.optionalString ( v.hostname != "" - ) "echo $(${pkgs.cjdns}/bin/publictoip6 ${v.publicKey}) ${v.hostname}" + ) "echo $(${pkgs.cjdns}/bin/cjdnstool util key2ip6 ${v.publicKey}) ${v.hostname}" ) (cfg.ETHInterface.connectTo // cfg.UDPInterface.connectTo) )} ''; @@ -268,7 +268,7 @@ in if [ -z "$CJDNS_PRIVATE_KEY" ]; then shopt -s lastpipe - ${pkg}/bin/makekeys | { read private ipv6 public; } + ${pkg}/bin/cjdnstool util keygen | { read private ipv6 public; } install -m 600 <(echo "CJDNS_PRIVATE_KEY=$private") /etc/cjdns.keys install -m 444 <(echo -e "CJDNS_IPV6=$ipv6\nCJDNS_PUBLIC_KEY=$public") /etc/cjdns.public diff --git a/nixos/tests/cjdns.nix b/nixos/tests/cjdns.nix index 52762f853e20..4bff3b15035f 100644 --- a/nixos/tests/cjdns.nix +++ b/nixos/tests/cjdns.nix @@ -105,7 +105,7 @@ in def cjdns_ip(machine): res = machine.succeed("ip -o -6 addr show dev tun0") - ip = re.split("\s+|/", res)[3] + ip = re.split("\\s+|/", res)[3] machine.log("has ip {}".format(ip)) return ip @@ -116,14 +116,14 @@ in # ping a few times each to let the routing table establish itself - alice.succeed("ping -c 4 {}".format(carol_ip6)) - bob.succeed("ping -c 4 {}".format(carol_ip6)) + alice.wait_until_succeeds("ping -c 4 {}".format(carol_ip6)) + bob.wait_until_succeeds("ping -c 4 {}".format(carol_ip6)) - carol.succeed("ping -c 4 {}".format(alice_ip6)) - carol.succeed("ping -c 4 {}".format(bob_ip6)) + carol.wait_until_succeeds("ping -c 4 {}".format(alice_ip6)) + carol.wait_until_succeeds("ping -c 4 {}".format(bob_ip6)) - alice.succeed("ping -c 4 {}".format(bob_ip6)) - bob.succeed("ping -c 4 {}".format(alice_ip6)) + alice.wait_until_succeeds("ping -c 4 {}".format(bob_ip6)) + bob.wait_until_succeeds("ping -c 4 {}".format(alice_ip6)) alice.wait_for_unit("httpd.service") From 0639f762d9ddff0032975235dff17f89a2a17006 Mon Sep 17 00:00:00 2001 From: Amadej Kastelic Date: Thu, 17 Jul 2025 20:13:20 +0200 Subject: [PATCH 3/6] cjdns: remove usage of with lib --- pkgs/by-name/cj/cjdns/package.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/cj/cjdns/package.nix b/pkgs/by-name/cj/cjdns/package.nix index 5c90ca7b4714..8334caec4890 100644 --- a/pkgs/by-name/cj/cjdns/package.nix +++ b/pkgs/by-name/cj/cjdns/package.nix @@ -80,11 +80,11 @@ rustPlatform.buildRustPackage rec { passthru.tests.basic = nixosTests.cjdns; - meta = with lib; { + meta = { homepage = "https://github.com/cjdelisle/cjdns"; description = "Encrypted networking for regular people"; - license = licenses.gpl3Plus; - maintainers = with maintainers; [ ehmry ]; - platforms = platforms.linux; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ ehmry ]; + platforms = lib.platforms.linux; }; } From 4b5c5664cc66ff707cb09431d00ad528cc85950f Mon Sep 17 00:00:00 2001 From: Amadej Kastelic Date: Wed, 23 Jul 2025 11:30:15 +0200 Subject: [PATCH 4/6] cjdns: enable darwin support --- pkgs/by-name/cj/cjdns/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/cj/cjdns/package.nix b/pkgs/by-name/cj/cjdns/package.nix index 8334caec4890..34199ed5b181 100644 --- a/pkgs/by-name/cj/cjdns/package.nix +++ b/pkgs/by-name/cj/cjdns/package.nix @@ -85,6 +85,6 @@ rustPlatform.buildRustPackage rec { description = "Encrypted networking for regular people"; license = lib.licenses.gpl3Plus; maintainers = with lib.maintainers; [ ehmry ]; - platforms = lib.platforms.linux; + platforms = lib.platforms.linux ++ lib.platforms.darwin; }; } From ac71292aa1deb1df1914029f45b1321d647da21a Mon Sep 17 00:00:00 2001 From: Amadej Kastelic Date: Wed, 23 Jul 2025 22:18:34 +0200 Subject: [PATCH 5/6] cjdns-tools: enable darwin support --- pkgs/by-name/cj/cjdns-tools/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/cj/cjdns-tools/package.nix b/pkgs/by-name/cj/cjdns-tools/package.nix index 9e68412928e6..90ab4d61ae82 100644 --- a/pkgs/by-name/cj/cjdns-tools/package.nix +++ b/pkgs/by-name/cj/cjdns-tools/package.nix @@ -42,7 +42,7 @@ stdenv.mkDerivation { description = "Tools for cjdns managment"; license = licenses.gpl3Plus; maintainers = [ ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; mainProgram = "cjdns-tools"; }; } From 72626fff03ab539951e0f0855acac2cad232c477 Mon Sep 17 00:00:00 2001 From: Amadej Kastelic Date: Wed, 23 Jul 2025 22:18:59 +0200 Subject: [PATCH 6/6] cjdns-tools: remove usage of with lib --- pkgs/by-name/cj/cjdns-tools/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/cj/cjdns-tools/package.nix b/pkgs/by-name/cj/cjdns-tools/package.nix index 90ab4d61ae82..43c2fb28cafb 100644 --- a/pkgs/by-name/cj/cjdns-tools/package.nix +++ b/pkgs/by-name/cj/cjdns-tools/package.nix @@ -37,12 +37,12 @@ stdenv.mkDerivation { cp -r node_modules $out/node_modules ''; - meta = with lib; { + meta = { homepage = "https://github.com/cjdelisle/cjdns"; description = "Tools for cjdns managment"; - license = licenses.gpl3Plus; + license = lib.licenses.gpl3Plus; maintainers = [ ]; - platforms = platforms.linux ++ platforms.darwin; + platforms = lib.platforms.linux ++ lib.platforms.darwin; mainProgram = "cjdns-tools"; }; }