All derivations fail: "builder for ... failed to produce output path for output 'out' at ..."

Hi all,

Thanks for making such an amazing system!

I’ve been using NixOS (dual-booted on an Intel Mac laptop) successfully for about two weeks now, admittedly without developing with Nix much, mostly just getting the hang of the system. I started writing my own derivations and using flakes yesterday, and now all custom derivations fail with the same message:

“builder for ‘/nix/store/{hash}-{name}.drv’ failed to produce output path for output ‘out’ at ‘/nix/store/{same hash}-{name}.drv.chroot/nix/store/{different hash}-{name}’”

I’ve tried rolling back two weeks, garbage-collecting, running with --repair, running in a different directory, running with sudo, sudo -i, etc.

The system and builtin derivations run fine; it seems like anything local using stdenv.mkDerivation fails. Running nix flake new test && cd test && nix build runs fine, presumably because the generated flake.nix uses a prebuilt derivation and not stdenv.mkDerivation? Even if I don’t use flakes (nix-build whatever.nix), write an empty builder.sh and choose it as the builder, same error.

I apologize for giving such little helpful information, but I really can’t crack this open–even nix build --verbose just prints the same path ‘… will be built’ and nothing else.

Any help would be appreciated, even if it’s just to delete the whole OS and reinstall (fingers crossed not, though)!

If it helps, here’s my entire configuration.nix (nothing changed in the past week except adding packages, and removing them didn’t help):

{ config, lib, modulesPath, options, pkgs, specialArgs }: {
  boot.loader = {
    systemd-boot.enable = true;
    efi = {
      canTouchEfiVariables = true;
      efiSysMountPoint = "/boot/efi";
    };
  };
  environment.systemPackages = with pkgs; [
    git
    helix
  ];
  hardware.firmware = [
    (pkgs.stdenvNoCC.mkDerivation {
      name = "brcm-firmware";
      buildCommand = ''
        dir="$out/lib/firmware"
        mkdir -p "$dir"
        cp -r ${./firmware}/* "$dir"
      '';
    })
  ];
  i18n.defaultLocale = "en_US.UTF-8";
  imports = [
    ./hardware-configuration.nix
    "${builtins.fetchGit { url = "https://github.com/kekrby/nixos-hardware.git"; }}/apple/t2"
  ];
  networking = {
    hostName = "macbook-nixos";
    networkmanager.enable = true;
  };
  nix = {
    extraOptions = "experimental-features = nix-command flakes";
    package = pkgs.nixUnstable;
    settings.experimental-features = [ "flakes" "nix-command" ];
  };
  nixpkgs.config.allowUnfree = true; # :_(
  programs = {
    git = {
      enable = true;
      package = pkgs.git;
    };
    gnupg.agent = {
      enable = true;
      enableSSHSupport = true;
    };
    mtr.enable = true;
  };
  services = {
    openssh.enable = true;
    xserver = {
      desktopManager.gnome.enable = true;
      displayManager.gdm.enable = true;
      enable = true;
      layout = "us";
      libinput.enable = true;
    };
  };
  system = {
    autoUpgrade = {
      dates = "04:00";
      enable = true;
      flags = [ "--update-input" "nixpkgs" ];
      allowReboot = true;
    };
    copySystemConfiguration = true;
    stateVersion = "23.05";
  };
  time.timeZone = "America/Los_Angeles";
  users.users.will = {
    description = "Will";
    extraGroups = [ "networkmanager" "wheel" ];
    isNormalUser = true;
    packages = with pkgs; [
      cargo
      element-desktop
      firefox
      nil
      tree
    ];
  };
}

does building this derivation fail

nix build -f test.nix

test.nix

{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation {
  name = "atest";
  buildCommand = ''
    touch $out
  '';
}

Yes, that works! Changing from touch $out to echo Hi doesn’t work, though. So I’m assuming somehow the default builder isn’t making $out and then checking for it later?

A derivation must have atleast one output and all the outputs must be created. So there is no issue with your system

1 Like

Thanks so much. So, if I understand correctly, all derivations have to explicitly touch/mkdir $out?

They have to produce an output. Sometimes ~tests written as nix expressions will just touch if they ran cleanly, but the vast majority of expressions people write will produce a file or a directory of them.

(It doesn’t really matter how you achieve that; touch and mkdir aren’t special here.)

1 Like