What does "error X is not allowed to refer to the following paths" mean exactly?

I am getting the error at the end of my nix-build (see below).
This is with a nix file that was adapted from another that was working for me a few years ago.

I did set my nixpkgs to the latest - so I suppose an ‘unstable’ version, and I see some comments to the effect that this has caused other people problems.

Otherwise the entire build seems to complete and it’s only when the 'fixup phase" runs that this seems to happen.

I can’t find any references to the ghc path in the build products, other than the substring “ghc-9.6.5” appearing (as expected) in the paths generated for build products, but these aren’t paths back to an original compiler per se, merely a naming convention to indicate the compiler used.

Any ideas as to how to make this error go away? Is picking a particular nixpkgs archive the answer?

My nix file:

let
  # Fetch the external Git repository for the boa package
  boaPackage = builtins.fetchGit {
    url = "git@bitbucket.org:levans/boa.git";
    rev = "345ee367141c4771cd5bc43e5bea414a630a0000";
  };

  project-overlay = final: prev: {
      # Update to use ghc965
      ppilot-haskell-packages = prev.haskell.packages.ghc965.override {
        overrides = haskellPackagesNew: haskellPackagesOld: {
          mkDerivation = args: haskellPackagesOld.mkDerivation (args // {
            doCheck = false;
            doHaddock = false;
            enableSeparateDataOutput = false;

            # Ensure git is available during the build process
            nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ final.git ];

            postInstall = 
              let ghcName = "${haskellPackagesNew.ppilot.passthru.compiler.targetPrefix}${haskellPackagesNew.ppilot.passthru.compiler.haskellCompilerName}";
                  sysPlusGhc = "${haskellPackagesNew.ppilot.system}-${ghcName}";
                  ppilotName = haskellPackagesNew.ppilot.name;
                  fullDataPath = "share/${sysPlusGhc}/${ppilotName}";
              in
                ''
                  ln -sf "$out/${fullDataPath}/config" $out/config
                  ln -sf "$out/${fullDataPath}/static" $out/static
                  ln -sf "$out/${fullDataPath}/client" $out/client
                  ln -sf "$out/${fullDataPath}/clientpp" $out/clientpp
                  ln -sf "$out/${fullDataPath}/adminclient" $out/adminclient
                  ln -sf "$out/${fullDataPath}/tagcatalog" $out/tagcatalog
                '';
          });

          # Local project dependencies here
          ppilot = final.haskell.lib.dontCheck (haskellPackagesNew.callCabal2nix "ppilot" ./. { });
          boa = final.haskell.lib.dontCheck (haskellPackagesNew.callCabal2nix "boa" boaPackage { });
        };
      };

    #ppilot = final.haskell.lib.justStaticExecutables final.ppilot-haskell-packages.ppilot;
    ppilot = final.haskell.lib.justStaticExecutables (final.ppilot-haskell-packages.ppilot.overrideAttrs (oldAttrs: {
      nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [ final.git ];
    }));


    ppilot-dev-shell = final.ppilot-haskell-packages.shellFor {
      withHoogle = false;
      packages = hpkgs: [ hpkgs.ppilot hpkgs.gantt ];  # Add all necessary packages here
      buildInputs = [ ];
      nativeBuildInputs = [
        final.cabal-install
        final.ghcid
        final.git
        final.haskell.packages.ghc965.haskell-language-server
        final.haskell.packages.ghc965.fourmolu
      ];
    };
  };

  nixpkgs-src = builtins.fetchTarball {
    # Updated nixpkgs-unstable version
    name = "nixpkgs-for-ppilot";                                  
    url = "https://github.com/NixOS/nixpkgs/archive/cb8e8bbe7579a5283f6fae1dd40a5a7386db2f2f.tar.gz";
    sha256 = "0120nbmjp4l2scsrn7vxlv7jark0x41a71a7x4lk4mx8x1axwcyy";
  };
in
  import nixpkgs-src { overlays = [ project-overlay ]; }

The error:

buildPhase completed in 1 minutes 7 seconds
Running phase: haddockPhase
install: skipping file '/dev/fd/63', as it was replaced while being copied
Running phase: installPhase
install: skipping file '/dev/fd/63', as it was replaced while being copied
Installing library in /nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0/lib/ghc-9.6.5/lib/aarch64-osx-ghc-9.6.5/ppilot-0.1.0-IHc5YJ9MBFE57hqyEaM9n
Installing executable worker in /nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0/bin
Warning: The directory
/nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0/bin is not in the
system search path.
Installing executable ppilot in /nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0/bin
Warning: The directory
/nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0/bin is not in the
system search path.
Registering library for ppilot-0.1.0..
Running phase: fixupPhase
install: skipping file '/dev/fd/63', as it was replaced while being copied
checking for references to /private/tmp/nix-build-ppilot-0.1.0.drv-0/ in /nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0...
patching script interpreter paths in /nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0
stripping (with command strip and flags -S) in /nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0/lib /nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0/bin
error: output '/nix/store/gnqcjnlxl3i5bqcynn5w9n25vszrhgs3-ppilot-0.1.0' is not allowed to refer to the following paths:
/nix/store/cdjkhc6i9f508k3ysbn8l05bpb8wihbx-ghc-9.6.5

Following up…

I have tried:
find /nix/store/vjyhv79zk4vk5xqxx3rnqarcsnhav0yb-ppilot-0.1.0 -type f -exec grep -H '/nix/store/cdjkhc6i9f508k3ysbn8l05bpb8wihbx-ghc-9.6.5' {} \;

and there is absolutely nothing referencing that path.

There are a lot of paths that include the substring “ghc-9.6.5” because ghc produces paths that include the architecture and the compiler used to generate its output products. Surely just having a substring in a path that happens to be a substring in some other path isn’t illegal? The potential for that to happen is quite high I would imagine and that is far from encoding a particular nix store path into another store object.

I have also tried various verbose tracing flags in the hope of getting more information on what nix thinks is the location of the violation (where “/nix/store/cdjkhc6i9f508k3ysbn8l05bpb8wihbx-ghc-9.6.5” is actually referenced), but I can’t find anything that elucidates.

I have commented out all the postInstall stuff in my nix file. While this will be necessary to ensure that the built application has all the files that it needs at runtime, this isn’t necessary to test the nix build. It turns out that removing that didn’t help either… so it’s not from anything that is included for these ‘data files’.

So, this is quite frustrating. I have a black box that I don’t know how to penetrate and all my build seems to work right up to the point that I’m told the output is in violation of this illegal reference.

https://nixos.org/manual/nixpkgs/unstable/#haskell-packaging-helpers

Thank you.

I think “disallowGhcReference = false;” solved this.
Very much appreciated the pointer anyway - at least I’m on to the next problem.