Error: duplicate derivation output 'dist'


I am getting the error in the title, and can’t seem to find anything on Google about it. The traceback is as follows:

error: duplicate derivation output 'dist'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

       … while evaluating the attribute 'outputs' of the derivation 'python3.10-titan-'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

       … while evaluating the attribute 'drvPath'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/customisation.nix:213:7:

          212|     in commonAttrs // {
          213|       drvPath = assert condition; drv.drvPath;
             |       ^
          214|       outPath = assert condition; drv.outPath;

       … while checking the derivation 'packages.x86_64-linux.default'

       at /nix/store/sk4ga2wy0b02k7pnzakwq4r3jdknda4g-source/flattenTree.nix:16:9:

           15|       (sum // {
           16|         "${pathStr}" = val;
             |         ^
           17|       })

       … while checking flake output 'packages'

       at /nix/store/sk4ga2wy0b02k7pnzakwq4r3jdknda4g-source/default.nix:136:17:

          135|               {
          136|                 ${key} = (attrs.${key} or { })
             |                 ^
          137|                   // (appendSystem key system ret);

The code is a little difficult to follow, but I’ve posted it here.

Any help would be greatly appreciated!

That code is fairly horrifying, but I did notice one thing that really looks wrong:
You’re including both outputs and an expression that looks like it’s supposed to system-space outputs in the merge list at the end, but outputs is already system-spaced by eachDefaultSystem

Basically, I’m trying to change the order of the outputs a little, so that instead of doing something like the following:

packages = flake.packages.${system};
devShells = flake.devShells.${system};

I could do this instead:

inherit (flake.${system}) packages devShells;

It was working before, but the the moment I switched to 22.11, it started erroring out. Apparently it has something to do with this comment on reddit , where:

Python packages build with buildPythonPackage recently got the addition of sdist.

u/SuperSandro2000’s comment here made me realize that this wasn’t happening because of buildPythonPackage, but because of my definition of buildPythonApplication; because I’m merging the derivation of the package into the derivation of the application, outputs gets created twice, and therefore dist as well. All I had to do was filter out the outputs along with a small handful of other duplicate attributes while merging the two derivations.