Building yt-dlp nightly fails because of mv command error in fixupPhase

Using NixOS unstable and flakes.

I am trying to use an overlay to override the source for pkgs.yt-dlp to point to the source for the latest (at time of writing) nightly build. The overlay is defined in a module which is imported into my configuration.nix file.

Module with overlay:

{ config, pkgs, ... }: {
  nixpkgs.overlays = [
    (final: prev: {
      yt-dlp = prev.yt-dlp.overrideAttrs (
        finalAttrs: prevAttrs: {
          version = "2026.09.16.232951";
          src = pkgs.fetchzip {
            url = "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/download/${finalAttrs.version}/yt-dlp.tar.gz";
            hash = "sha256-eN6wNEdXOFuwjW0hB3OQMDUROvtNd3QV/O8kqbr/kug=";
          };
        }
      );
    })
  ];
}

The build fails when the fixupPhase tries to mv doc files frome one store paths to a nonempty directory in another store path.

Error:

> Moving /nix/store/k13z0dyw95nlpq5895lgk4ynqq8p7257-yt-dlp-2026.09.16.232951/share/doc to /nix/store/whpphr7qr79jxblz7jdvc12sn0h6d6da-yt-dlp-2026.09.16.232951-doc/share/doc
       > mv: cannot overwrite '/nix/store/whpphr7qr79jxblz7jdvc12sn0h6d6da-yt-dlp-2026.09.16.232951-doc/share/doc/yt_dlp': Directory not empty

To make sure this was not being caused by some junk left over from a previous failed build, I ran nix-store --gc and verified that the paths in the error were removed from /nix/store. I tried the build again and got the same error. I have no problems when building yt-dlp using the original source in pkgs.yt-dlp. This only happens with the nightly source. Does anyone know how to resolve this? Any help would be appreciated.

Relevant error logs:

building '/nix/store/cvja0fj6b9hvrryam61rcdd2zjfj4c6c-yt-dlp-2026.09.16.232951.drv'...
error: Cannot build '/nix/store/cvja0fj6b9hvrryam61rcdd2zjfj4c6c-yt-dlp-2026.09.16.232951.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/4w0n6picp1i39lylhy7gd1270q399j71-yt-dlp-2026.09.16.232951-dist
         /nix/store/k13z0dyw95nlpq5895lgk4ynqq8p7257-yt-dlp-2026.09.16.232951
         /nix/store/r8s423jx6xcrisgfgny8ck4ryqakg7x3-yt-dlp-2026.09.16.232951-man
         /nix/store/whpphr7qr79jxblz7jdvc12sn0h6d6da-yt-dlp-2026.09.16.232951-doc
       Last 25 log lines:
       > Creating a wheel...
       > pypa build flags: --no-isolation --outdir dist/ --wheel
       > * Getting build dependencies for wheel...
       > * Building wheel...
       > Successfully built yt_dlp-2026.9.16.232951-py3-none-any.whl
       > Finished creating a wheel...
       > /build/source/dist /build/source
       > Unpacking to: unpacked/yt_dlp-2026.9.16.232951...OK
       > Repacking wheel as ./yt_dlp-2026.9.16.232951-py3-none-any.whl...OK
       > /build/source
       > Finished executing pypaBuildPhase
       > Running phase: pythonRuntimeDepsCheckHook
       > Executing pythonRuntimeDepsCheck
       > Checking runtime dependencies for yt_dlp-2026.9.16.232951-py3-none-any.whl
       > Finished executing pythonRuntimeDepsCheck
       > Running phase: installPhase
       > Executing pypaInstallPhase
       > Successfully installed yt_dlp-2026.9.16.232951-py3-none-any.whl
       > Finished executing pypaInstallPhase
       > Running phase: pythonOutputDistPhase
       > Executing pythonOutputDistPhase
       > Finished executing pythonOutputDistPhase
       > Running phase: fixupPhase
       > Moving /nix/store/k13z0dyw95nlpq5895lgk4ynqq8p7257-yt-dlp-2026.09.16.232951/share/doc to /nix/store/whpphr7qr79jxblz7jdvc12sn0h6d6da-yt-dlp-2026.09.16.232951-doc/share/doc
       > mv: cannot overwrite '/nix/store/whpphr7qr79jxblz7jdvc12sn0h6d6da-yt-dlp-2026.09.16.232951-doc/share/doc/yt_dlp': Directory not empty
       For full logs, run:
         nix log /nix/store/cvja0fj6b9hvrryam61rcdd2zjfj4c6c-yt-dlp-2026.09.16.232951.drv
error: Cannot build '/nix/store/cvja0fj6b9hvrryam61rcdd2zjfj4c6c-yt-dlp-2026.09.16.232951.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/4w0n6picp1i39lylhy7gd1270q399j71-yt-dlp-2026.09.16.232951-dist
         /nix/store/k13z0dyw95nlpq5895lgk4ynqq8p7257-yt-dlp-2026.09.16.232951
         /nix/store/r8s423jx6xcrisgfgny8ck4ryqakg7x3-yt-dlp-2026.09.16.232951-man
         /nix/store/whpphr7qr79jxblz7jdvc12sn0h6d6da-yt-dlp-2026.09.16.232951-doc
       Last 25 log lines:
       > Creating a wheel...
       > pypa build flags: --no-isolation --outdir dist/ --wheel
       > * Getting build dependencies for wheel...
       > * Building wheel...
       > Successfully built yt_dlp-2026.9.16.232951-py3-none-any.whl
       > Finished creating a wheel...
       > /build/source/dist /build/source
       > Unpacking to: unpacked/yt_dlp-2026.9.16.232951...OK
       > Repacking wheel as ./yt_dlp-2026.9.16.232951-py3-none-any.whl...OK
       > /build/source
       > Finished executing pypaBuildPhase
       > Running phase: pythonRuntimeDepsCheckHook
       > Executing pythonRuntimeDepsCheck
       > Checking runtime dependencies for yt_dlp-2026.9.16.232951-py3-none-any.whl
       > Finished executing pythonRuntimeDepsCheck
       > Running phase: installPhase
       > Executing pypaInstallPhase
       > Successfully installed yt_dlp-2026.9.16.232951-py3-none-any.whl
       > Finished executing pypaInstallPhase
       > Running phase: pythonOutputDistPhase
       > Executing pythonOutputDistPhase
       > Finished executing pythonOutputDistPhase
       > Running phase: fixupPhase
       > Moving /nix/store/k13z0dyw95nlpq5895lgk4ynqq8p7257-yt-dlp-2026.09.16.232951/share/doc to /nix/store/whpphr7qr79jxblz7jdvc12sn0h6d6da-yt-dlp-2026.09.16.232951-doc/share/doc
       > mv: cannot overwrite '/nix/store/whpphr7qr79jxblz7jdvc12sn0h6d6da-yt-dlp-2026.09.16.232951-doc/share/doc/yt_dlp': Directory not empty
       For full logs, run:
         nix log /nix/store/cvja0fj6b9hvrryam61rcdd2zjfj4c6c-yt-dlp-2026.09.16.232951.drv
error: Cannot build '/nix/store/xqw2x9icycbc5z18szi11jiklzcd4ca8-system-path.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/vmdzm8dsa00wsmnw4k7aiayjrg6sd644-system-path
error: Cannot build '/nix/store/84qy87q02w3xwci6x6acw785wz5xycfr-nixos-system-blackbox-26.11.20260923.4975466.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/79g71xvdj41f1ki7r66s8hirqcg65s72-nixos-system-blackbox-26.11.20260923.4975466
Command 'nix --extra-experimental-features 'nix-command flakes' build --print-out-paths '/user/user/nixos#nixosConfigurations."blackbox".config.system.build.toplevel' --no-link' returned non-zero exit status 1.

My best guess is that you probably need to overrideAttrs the fixupPhase to whatever makes sense.

nix-shell or nix develop can be used to step through builds. At least for nix-shell, declare -f genericBuild shows you how a build gets run. You may need to override the envvar $out, especially since fixupPhase happens after installPhase.

I thought this might be the thing to do as well. Though, when I look at the nix code for yt-dlp, it does not define fixupPhase. I have not yet found where the fixupPhase actions are defined.

These are new to me. I will take a look at them. Thanks.

Is there a reason you’re using the yt-dlp-nightly-builds release instead of

fetchFromGitHub {
  owner = "yt-dlp";
  repo = "yt-dlp";
  rev = "c7fb478d21e9e59524befbe23f7801bb267fb880"; # https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2026.09.16.232951
  hash = "";
}

?

I’m guessing, at a glance, that the release builds may contain things in share/doc/yt_dlp that the source does not (which are copied into $doc by the standard build scripts), and that will end up conflicting with the install -Dm644 Changelog.md README.md -t "$doc/share/doc/yt_dlp" line in the package script.

hmmm… I see what you mean and that’s suggestive that the phase is defined in stdenv so it’s surprising that it would break.

If I do nix-shell '<nixpkgs/default.nix>' -A yt-dlp and then in that shell do definePhases; declare -f fixupPhase I get:

fixupPhase () 
{ 
    local output;
    for output in $(getAllOutputNames);
    do
        if [ -e "${!output}" ]; then
            chmod -R u+w,u-s,g-s "${!output}";
        fi;
    done;
    runHook preFixup;
    local output;
    for output in $(getAllOutputNames);
    do
        prefix="${!output}" runHook fixupOutput;
    done;
    recordPropagatedDependencies;
    if [ -n "${setupHook:-}" ]; then
        mkdir -p "${!outputDev}/nix-support";
        substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook";
    fi;
    if [ -n "${setupHooks:-}" ]; then
        mkdir -p "${!outputDev}/nix-support";
        local hook;
        for hook in ${setupHooks[@]};
        do
            local content;
            consumeEntire content < "$hook";
            substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook";
            unset -v content;
        done;
        unset -v hook;
    fi;
    if [ -n "${propagatedUserEnvPkgs[*]:-}" ]; then
        mkdir -p "${!outputBin}/nix-support";
        printWords "${propagatedUserEnvPkgs[@]}" > "${!outputBin}/nix-support/propagated-user-env-packages";
    fi;
    runHook postFixup
}

There isn’t a mv directly referenced (maybe it’s indirect), but if you can step through the build and see whether or not you reproduce the error then maybe that will help.

Also I’m realizing that yt-dlp is a multiple output derivation. Specifically, it seems to produce out, doc, dist, man – so you may need to override all of these outputs/env-vars to reasonable directories in order to test instead of just $out. For sure at least $doc since that seems to be the error issue for you.

(EDIT: since I know when replies come close together it’s easy to miss one – see rhendric’s suggestion above, I think it makes sense)

I just did not figure out how to do it that way. I would prefer this, actually. The documentation on the yt-dlp repository sort of led me to trying to do it with the yt-dlp-nightly-builds repository which led to using fetchzip. I will try this way and report back. Thanks.

The solution given by @rhendric worked. Thank you, @rhendric and @withakay, for your help.

Working module code:

{ config, pkgs, ... }: {
  nixpkgs.overlays = [
    (final: prev: {
      yt-dlp = prev.yt-dlp.overrideAttrs (
        finalAttrs: prevAttrs: {
          version = "2026.09.16.232951";
          src = pkgs.fetchFromGitHub {
            owner = "yt-dlp";
            repo = "yt-dlp";
            rev = "c7fb478d21e9e59524befbe23f7801bb267fb880"; # https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2026.09.16.232951
            hash = "sha256-f98zqG5ov/v6EGZxMqeXSRfKegb+XpEMQD/U5oX7F78=";
          };
        }
      );
    })
  ];
}

Note that checking the version with yt-dlp --version still returns 2026.08.19 which is the current stable release, but checking with readlink “$(which yt-dlp)” returns /nix/store/6dr56pxx5m0m4qsfqgmd7clyhj9av876-yt-dlp-2026.09.16.232951/bin/yt-dlp which confirms that I am actually using the nightly release configured in my overlay. This is my first time using a nightly release; I have used master before. I suppose this is the expected behavior for yt-dlp --version with nightly releases; I saw nothing in the manpage about it.