Zon2Nix & ZigDeps: unable to connect to server: NameServerFailure

I’m trying to package up rhine for the new river compositor and I’m running into an issue trying to pull zig dependencies from Codeberg.

No matter what method I use, either zon2nix or zig.deps, I end up getting the exact same build errors

error: builder for '/nix/store/y3hsr67y7awsvsh6xf36hsw3z3gs6w7q-rhine-0.3.0.drv' failed with exit code 1;
       last 19 log lines:
       > Using versionCheckHook
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/jvd75z1h0ys2rd4b7xw7jqiblii7cida-source
       > source root is source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > Running phase: buildPhase
       > zig build flags: -j16 -Dcpu=baseline --release=safe
       > /build/source/build.zig.zon:8:20: error: unable to connect to server: NameServerFailure
       >             .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.6.0.tar.gz",
       >                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > /build/source/build.zig.zon:12:20: error: unable to connect to server: NameServerFailure
       >             .url = "https://codeberg.org/Games-by-Mason/mr_tween/archive/v0.1.0.tar.gz",
       >                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > /build/source/build.zig.zon:16:20: error: unable to discover remote git server capabilities: NameServerFailure
       >             .url = "git+https://codeberg.org/Sivecano/libtributary#ad5ee12ecae34c6aac55c55eeffce50f85cb3856",
       >                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > 
       For full logs, run:
          nix log /nix/store/y3hsr67y7awsvsh6xf36hsw3z3gs6w7q-rhine-0.3.0.drv

Here’s my (very rough) package.nix

{
  lib,
  pkgs,
  ...
}:

pkgs.stdenv.mkDerivation (finalAttrs: {
  pname = "rhine";
  version = "0.3.0";
  strictDeps = true;

  src = pkgs.fetchFromCodeberg {
    #url = "https://codeberg.org/Sivecano/rhine/archive/${finalAttrs.version}.tar.gz";
    #hash = "sha256-1urSOudD12Ge/hy3mGFfGNQAKLjqvuyV+cO1T4HloYs=";
    owner = "Sivecano";
    repo = "rhine";
    tag = finalAttrs.version;
    hash = "sha256-1urSOudD12Ge/hy3mGFfGNQAKLjqvuyV+cO1T4HloYs=";
  };

  nativeBuildInputs = with pkgs; [
    zig_0_16
    pkg-config
  ];

  buildInputs = with pkgs; [
    wayland-scanner
    river
    libxkbcommon
    wayland
    dbus
    wayland-protocols
  ];
  
  zigDeps = pkgs.zig_0_16.fetchDeps {
    inherit (finalAttrs) src pname version;
    hash = "sha256-wvnECiDfK17uKGySe2SYEkpHL0RdRQTlS+b8zGw2F9g=";
  };

  postConfigure = ''
    ln -s ${finalAttrs.zigDeps} $ZIG_GLOBAL_CACHE_DIR/p
  '';

  nativeInstallCheckInputs = with pkgs; [versionCheckHook];
  versionCheckProgramArg = "-version";

  postInstall = ''
    install rhine.desktop -Dt $out/share/wayland-sessions
  '';

  doCheck = true;
  doInstallCheck = true;
})

And, although this exact package doesn’t utilize it, this is what my build.zon.nix file looks like when I decide to use zon2nix

# generated by zon2nix (https://github.com/nix-community/zon2nix)

{ linkFarm, fetchzip, fetchgit }:

linkFarm "zig-packages" [
  {
    name = "mr_tween-0.1.0-WbH78YcBAQD3RF4QfCYFF6EJCYzAzdIU4BHCj0pFI5yq";
    path = fetchzip {
      url = "https://codeberg.org/Games-by-Mason/mr_tween/archive/v0.1.0.tar.gz";
      hash = "sha256-+f3klYdTikb7qoggebyOET+xHH9IuZt78MQTfpJOZjM=";
      extension = "tar.gz";
    };
  }
  {
    name = "tributary-0.4.0-tqCfW5fFAAC_PBxqMMwGJRlbwU8XThn9b2zIieRvQgDX";
    path = fetchgit {
      url = "https://codeberg.org/Sivecano/libtributary";
      rev = "ad5ee12ecae34c6aac55c55eeffce50f85cb3856";
      hash = "sha256-PKtVtnUbfjOkAkYOaUCaMgAT/2rplMxFESgKNL9DFJk=";
    };
  }
  {
    name = "wayland-0.6.0-lQa1kqz8AQADQmdNJsNhLoNHcnEGEUjrOaPV-dtEnEmX";
    path = fetchzip {
      url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.6.0.tar.gz";
      hash = "sha256-3m/ITNhZUJ/5uD/Tqm+0uZSktGoYgWF5oldOqOCUkIE=";
      extension = "tar.gz";
    };
  }
]

I tacked on the extension key for the zip archives after reading though this issue which also cued me into zig.fetchDeps. I also read this discourse thread discussing the current packaging workflow for zig, which gave me the resources for trying a few different dependency management methods, neither of which have worked.

After researching, I’m thoroughly convinced that this is a Codeberg issue (maybe too much bot prevention?). Am I missing something here that would make fetching these tarballs simply impossible using my current setup? Any help is appreciated.

I do recommend using fetchDeps, though you’re missing the preConfigure hook.

postConfigure = ''
  ln -s $zigDeps $ZIG_GLOBAL_CACHE_DIR/p
'';

Also you don’t need to specify .hook since the hook will automatically be loaded in.

Ok, that’s certainly changed things as I’m getting different errors now. I must have had some typos the last time I tried this. I’ve also updated my horribly hacked up package.nix to reflect the file I’m using now.

b1kfzlvqiwbcpw4sd2j3v63vqab3vg-zig-0.16.0/lib/zig/ --listen=-
       > install -C .zig-cache/o/33324a2b19574f0b2ea007a5d237ff02/rhine /build/source/zig-out/bin/rhine
       > buildPhase completed in 1 minutes 31 seconds
       > Running phase: checkPhase
       > zig check flags: -j16 -Dcpu=baseline --release=safe
       > pkg-config --variable=pkgdatadir wayland-scanner
       > pkg-config --variable=pkgdatadir wayland-protocols
       > pkg-config river-protocols --variable=pkgdatadir
       > info: access the help menu with "zig build -h"
       > error: no step named 'test'
       > error: the following build command failed with exit code 1:
       > .zig-cache/o/976000f9880524155d01cbf72ded8392/build /nix/store/kbb1kfzlvqiwbcpw4sd2j3v63vqab3vg-zig-0.16.0/bin/zig /nix/store/kbb1kfzlvqiwbcpw4sd2j3v63vqab3vg-zig-0.16.0/lib/zig /build/source .zig-cache /build/tmp.fQEaZFXn3A --seed 0x1c25174f -Z7908611a75f81679 test -j16 -Dcpu=baseline --release=safe --verbose
       For full logs, run:
         nix log /nix/store/1iqqsf6bfy9invi4jgfdadad4np4kdq4-rhine-0.3.0.drv

Ah yeah, there’s no unit tests so just doCheck = false.

Oof. It’s been a long day. Of course that’s the fix.

Ok. I got a successful build off of this, so I’m marking it solved. Thanks for your help!