nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 20.03 51 lines 1.9 kB view raw
1{ stdenv, go, buildGoModule, fetchgit }: 2 3buildGoModule rec { 4 pname = "gotools-unstable"; 5 version = "2019-11-14"; 6 rev = "4191b8cbba092238a318a71cdff48b20b4e1e5d8"; 7 8 src = fetchgit { 9 inherit rev; 10 url = "https://go.googlesource.com/tools"; 11 sha256 = "16m62m303j4wqfjr1401xpqpb9m11bs6qc2dhf6x2za2d9pycish"; 12 }; 13 14 # Build of golang.org/x/tools/gopls fails with: 15 # can't load package: package golang.org/x/tools/gopls: unknown import path "golang.org/x/tools/gopls": cannot find module providing package golang.org/x/tools/gopls 16 # That is most probably caused by golang.org/x/tools/gopls containing a separate Go module. 17 # In order to fix this, we simply remove the module. 18 # Note that build of golang.org/x/tools/cmd/gopls provides identical binary as golang.org/x/tools/gopls. 19 # See https://github.com/NixOS/nixpkgs/pull/64335. 20 postPatch = '' 21 rm -rf gopls 22 ''; 23 24 modSha256 = "16cfzmfr9jv8wz0whl433xdm614dk63fzjxv6l1xvkagjmki49iy"; 25 26 postConfigure = '' 27 # Make the builtin tools available here 28 mkdir -p $out/bin 29 eval $(go env | grep GOTOOLDIR) 30 find $GOTOOLDIR -type f | while read x; do 31 ln -sv "$x" "$out/bin" 32 done 33 export GOTOOLDIR=$out/bin 34 ''; 35 36 excludedPackages = "\\(" 37 + stdenv.lib.concatStringsSep "\\|" ([ "testdata" ] ++ stdenv.lib.optionals (stdenv.lib.versionAtLeast go.meta.branch "1.5") [ "vet" "cover" ]) 38 + "\\)"; 39 40 # Set GOTOOLDIR for derivations adding this to buildInputs 41 postInstall = '' 42 mkdir -p $out/nix-support 43 substituteAll ${../../go-modules/tools/setup-hook.sh} $out/nix-support/setup-hook.tmp 44 cat $out/nix-support/setup-hook.tmp >> $out/nix-support/setup-hook 45 rm $out/nix-support/setup-hook.tmp 46 ''; 47 48 # Do not copy this without a good reason for enabling 49 # In this case tools is heavily coupled with go itself and embeds paths. 50 allowGoReference = true; 51}