Commit 04c3ba56 authored by Taeer Bar-Yam's avatar Taeer Bar-Yam
Browse files

stdenv: fix inputDerivation in case of __structuredAttrs

Setting allowedReferences to null seems to only work as a fluke. It
doesn't work with outputChecks, and I couldn't get it to work at all
when declaring my own derivation manually (I'm honestly still unsure why
it works at all as-is in inputDerivation)

In any case, Rather than setting allowedReferences etc to values that
mimic the default behaviour, we can remove those attributes to get the
default behaviour.
parent 23644a2b
Loading
Loading
Loading
Loading
+13 −21
Original line number Diff line number Diff line
@@ -860,12 +860,23 @@ let
      # for a fixed-output derivation, the corresponding inputDerivation should
      # *not* be fixed-output. To achieve this we simply delete the attributes that
      # would make it fixed-output.
      deleteFixedOutputRelatedAttrs = lib.flip removeAttrs [
      fixedOutputRelatedAttrs = [
        "outputHashAlgo"
        "outputHash"
        "outputHashMode"
      ];

      # inputDerivation produces the inputs; not the outputs, so any
      # restrictions on what used to be the outputs don't serve a purpose
      # anymore.
      outputCheckAttrs = [
        "allowedReferences"
        "allowedRequisites"
        "disallowedReferences"
        "disallowedRequisites"
        "outputChecks"
      ];

    in

    extendDerivation validity.handled (
@@ -876,7 +887,7 @@ let
        # needed to enter a nix-shell with
        #   nix-build shell.nix -A inputDerivation
        inputDerivation = derivation (
          deleteFixedOutputRelatedAttrs derivationArg
          removeAttrs derivationArg (fixedOutputRelatedAttrs ++ outputCheckAttrs)
          // {
            # Add a name in case the original drv didn't have one
            name = "inputDerivation" + lib.optionalString (derivationArg ? name) "-${derivationArg.name}";
@@ -911,25 +922,6 @@ let
              ''
            ];
          }
          // (
            let
              sharedOutputChecks = {
                # inputDerivation produces the inputs; not the outputs, so any
                # restrictions on what used to be the outputs don't serve a purpose
                # anymore.
                allowedReferences = null;
                allowedRequisites = null;
                disallowedReferences = [ ];
                disallowedRequisites = [ ];
              };
            in
            if __structuredAttrs then
              {
                outputChecks.out = sharedOutputChecks;
              }
            else
              sharedOutputChecks
          )
        );

        inherit passthru overrideAttrs;