Using DNS in a nix derivation? Temporary failure in name resolution

I’m using a NixOS overlay to get a newer version of a package. All goes well until the step in the build that does this:

wget -O scintilla523.tgz https://www.scintilla.org/scintilla523.tgz
--2022-07-23 13:24:46--  https://www.scintilla.org/scintilla523.tgz
Resolving www.scintilla.org (www.scintilla.org)... failed: Temporary failure in name resolution.
wget: unable to resolve host address 'www.scintilla.org'
make: *** [Makefile:451: scintilla523.tgz] Error 4

That same command works fine at a bash prompt, so it seems there’s something not available in the build environment that I need. Is there something I need to add? Below is my default.nix; I’ve marked all the changes I made from the current version in nixpkgs.


{ lib, stdenv, fetchFromGitHub, fetchurl, gtk2, glib, pkg-config, unzip, ncurses, zip, wget }:
# ORIGINAL { lib, stdenv, fetchFromGitHub, fetchurl, gtk2, glib, pkg-config, unzip, ncurses, zip }:

stdenv.mkDerivation rec {
  version = "11.3.1";
# ORIGINAL  version = "11.3";
  pname = "textadept";

  nativeBuildInputs = [ pkg-config unzip zip wget ];
# ORIGINAL  nativeBuildInputs = [ pkg-config unzip zip ];
  buildInputs = [
    gtk2 ncurses glib
  ];

  enableParallelBuilding = true;

  src = fetchFromGitHub {
    name = "textadept11";
    owner = "mhwombat";
# ORIGINAL    owner = "orbitalquark";
    repo = "textadept";
    rev = "textadept_${version}";
    sha256 = "sha256-SlhwwUeCmb3iLv9fEVQDKU5Wm/ZC9BZdlIjtNKOQTxk=";
# ORIGINAL    sha256 = "sha256-C7J/Qr/58hLbyw39R+GU4wot1gbAXf51Cv6KGk3kg30=";
  };

  preConfigure =
    lib.concatStringsSep "\n" (lib.mapAttrsToList (name: params:
      "ln -s ${fetchurl params} $PWD/src/${name}"
    ) (import ./deps.nix)) + ''

    cd src
    make deps
  '';

  postBuild = ''
    make curses
  '';

  preInstall = ''
    mkdir -p $out/share/applications
    mkdir -p $out/share/pixmaps
  '';

  postInstall = ''
    make curses install PREFIX=$out MAKECMDGOALS=curses
  '';

  makeFlags = [
    "PREFIX=$(out)"
    "WGET=true"
    "PIXMAPS_DIR=$(out)/share/pixmaps"
  ];

  meta = with lib; {
    description = "An extensible text editor based on Scintilla with Lua scripting.";
    homepage = "http://foicica.com/textadept";
    license = licenses.mit;
    maintainers = with maintainers; [ raskin mirrexagon patricksjackson ];
    platforms = platforms.linux;
  };
}

Nix derivation do not have access to the network. This is by design.

If you want to download something, you must do so in a fixed-output-derivation.

2 Likes

More specifically, you’ll probably need to figure out how to build this package if that is set to false, and provide the inputs by some other means (likely a fetchurl and then some cp invocation to put it where this build script expects it).

2 Likes

For anyone needing a concrete example of how to download “extra stuff” required by a build, here’s how it’s done in the nixpkgs derivation for textadept. In the preConfigure section, before invoking make, they have:

lib.concatStringsSep "\n" (lib.mapAttrsToList (name: params:
  "ln -s ${fetchurl params} $PWD/src/${name}"
) (import ./deps.nix)) + ''

This references a separate file called deps.nix for all the “extra stuff”. That file looks like this:

{
  "scintilla524.tgz" = {
    url = "https://www.scintilla.org/scintilla524.tgz";
    sha256 = "sha256-Su8UiMmkOxcuBat2JWYEnhNdG5HKnV1fn1ClnJhazGY=";
  };
  .. similarly for other dependencies
}
1 Like