buildGoModule: output is not allowed to refer to the following paths

This derivation is able to build:

{ buildGoModule, fetchFromGitHub, lib }:
buildGoModule rec {
  pname = "spicetify-cli";
  version = "0.9.6";
  src = fetchFromGitHub {
    owner = "khanhas";
    repo = "spicetify-cli";
    rev = "v${version}";
    sha256 = "1v29qscbrzx810pbgwspxfwcrl7kl3k9r04rb3l6kbs1s3rn3hmi";
  };
  modSha256 = "1q6vvy2xz2wm2wzpjk04hbfmsjm72wfa3kxfnnc8b4gxhdhw50ql";
}

But if I add a fixupPhase, it no longer builds:

{ buildGoModule, fetchFromGitHub, lib }:
buildGoModule rec {
  pname = "spicetify-cli";
  version = "0.9.6";
  src = fetchFromGitHub {
    owner = "khanhas";
    repo = "spicetify-cli";
    rev = "v${version}";
    sha256 = "1v29qscbrzx810pbgwspxfwcrl7kl3k9r04rb3l6kbs1s3rn3hmi";
  };
  modSha256 = "1q6vvy2xz2wm2wzpjk04hbfmsjm72wfa3kxfnnc8b4gxhdhw50ql";
  fixupPhase = ''
   ls
  '';
}

Outputting the following error:

post-installation fixup
CustomApps  README.md     go.mod       install_curl.ps1  src
Extensions  Themes        go.sum       jsHelper          task.ps1
LICENSE     globals.d.ts  install.ps1  spicetify.go
output '/nix/store/w33ks10s0larsv6h74b7b0nsfizyayac-spicetify-cli-0.9.6' is not allowed to refer to the following paths:
  /nix/store/sraiappiiwhfs09mgsg0aplmjw6lglln-go-1.13.5

Pinned nixpkgs to reproduce this: (I think I did this correctly? It’s the most recent commit at the time of writing)

nix-build -E 'let
  nixpkgs = (import <nixpkgs> {}).fetchFromGitHub {
    owner = "nixOS";
    repo = "nixpkgs-channels";
    rev = "e1eedf29e5d22e6824e614d75449b75a2e3455d6";
    sha256 = "1v237cgfkd8sb5f1r08sms1rxygjav8a1i1jjjxyqgiszzpiwdx7";
  };
in with import nixpkgs {}; callPackage ./default.nix {}'

However, I don’t get an error if I replace fixupPhase with postInstall.

What am I doing wrong?

Thanks!

The standard environment has a default fixupPhase that you’re overwriting. That default fixupPhase is probably doing something to remove the unnecessary dependency (such as stripping binaries).

1 Like