"./configure: cannot execute" during 'nix build' but not during 'nix develop -i'

Flake contents:
(Ignore the GOMAXPROCS line, that’s a thread for another day)

{
  description = "A reimplementation of Sandstorm in Go";

  # Nixpkgs / NixOS version to use.
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-23.05";
  };

  outputs = { self, nixpkgs }:
    let
      # System types to support.
      supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];

      # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
      forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

      # Nixpkgs instantiated for supported system types.
      nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
    in
    {
      # Provide some binary packages for selected system types.
      packages = forAllSystems (system:
        let
          pkgs = nixpkgsFor.${system};
          go-capnp = pkgs.fetchFromGitHub {
            name = "go-capnp";
            owner = "capnproto";
            repo = "go-capnp";
            rev = "main";
            hash = "sha256-P6YP5b5Bz5/rS1ulkt1tSr3mhLyxxwgCin4WRFErPGM=";
          };
          tempest-src = pkgs.fetchFromGitHub {
            name = "tempest-src";
            owner = "troyjfarrell";
            repo = "tempest";
            rev = "main";
            hash = "sha256-V2+4VXqxbUpTWYrfzxpblzbsJKhAPXe5SoCii3+zxow=";
          };
        in rec
        {
          capnpc-go = pkgs.buildGoModule {
            name = "capnpc-go";
            pname = "capnpc-go";
            src = go-capnp;
            sourceRoot = "go-capnp";
            vendorSha256 = "sha256-DRNbv+jhIHzoBItuiQykrp/pD/46uysFbazLJ59qbqY=";
            buildPhase = ''
              go install ./capnpc-go
            '';
          };
          tempest = pkgs.stdenv.mkDerivation {
            name = "tempest";
            pname = "tempest";
            version = "alpha";
            srcs = [
              tempest-src
              go-capnp
            ];

            GOMAXPROCS = "1";

            sourceRoot = "tempest-src";
            patches = [ ./no-chown.patch ];
            preConfigure = ''
              export XDG_CACHE_HOME=$TMPDIR/.cache
              export GOPATH=$XDG_CACHE_HOME/go
            '';
            configureFlags = [
              "--with-go-capnp=../go-capnp"
            ];

            nativeBuildInputs = with pkgs; [
              go
              tinygo
              capnproto
              bpftools
              capnpc-go
            ];
          };
        });

      defaultPackage = forAllSystems (system: self.packages.${system}.tempest);
    };
}

When I run ‘nix build’ I get the following:

error: builder for '/nix/store/lvb5nnwcvlzjgk6jvrfqcbwpv4q7f8rz-tempest.drv' failed with exit code 127;
       last 10 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/hlhn8pm125mrykfm7ym6pj1628lssayv-tempest-src
       > unpacking source archive /nix/store/wsjcwz211ybfdd7yil0xssy5jlbzyx36-go-capnp
       > source root is tempest-src
       > patching sources
       > applying patch /nix/store/bd8jz4bv2jqqspqxw6830ci79g1an1in-no-chown.patch
       > patching file internal/make/make.go
       > configuring
       > configure flags: --prefix=/nix/store/2ylhnzcfkcjhg9rxl29djzz2ibah46v0-tempest --with-go-capnp=../go-capnp
       > /nix/store/gv2cl6qvvslz5h15vqd89f1rpvrdg5yc-stdenv-linux/setup: line 1299: ./configure: cannot execute: required file not found
       For full logs, run 'nix log /nix/store/lvb5nnwcvlzjgk6jvrfqcbwpv4q7f8rz-tempest.drv'.

However, when I run ‘nix develop -i’ and step through the phases, configurePhase runs just fine.

../go-capnp path is possibly wrong?

Debug with ls and --keep-failed to look at the configure.log

Many thanks for the reply. Could you be more specific on what I should be looking for?

[nixos@nixos:/tmp/nix-build-tempest.drv-0]$ ls
env-vars  go-capnp  tempest-src

I don’t seem to have a ‘configure.log’, even when using ‘nix develop’. I assume that’s because the configure script is just a wrapper around a go invocation:

Thought it was a gnu configure which logs to configure.log.

The shebang line in that file could be the issue since there’s no /usr/bin/env in the sandbox, try patchShebangs ./configure
in postPatch

Yep - that was the issue, thank you very much!

1 Like