Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildGoModule fails to build derivations with more than one subPackage #63923

Closed
gazally opened this issue Jun 29, 2019 · 1 comment · Fixed by #63936
Closed

buildGoModule fails to build derivations with more than one subPackage #63923

gazally opened this issue Jun 29, 2019 · 1 comment · Fixed by #63936
Assignees

Comments

@gazally
Copy link
Contributor

gazally commented Jun 29, 2019

Issue description

When more than one child package is given in subPackages, buildGoModule fails to build the second one.

Steps to reproduce

Build this derivation:

{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
  pname = "yggdrasil";
  version = "0.3.5";

  src = fetchFromGitHub {
    owner = "yggdrasil-network";
    repo = "yggdrasil-go";
    rev = "v${version}";
    sha256 = "0cbj9hqrgn93jlybf3mfpffb68yyizxlvrsh1s5q21jv2lhhjcwj";
  };

  modSha256 = "1r942mqlq9lqxizxi33768jp4j706mwa2fliz0qbkh98r4ri2292";

  subPackages = [ "cmd/yggdrasilctl" "cmd/yggdrasil"];

  buildFlagsArray = ''
     -ldflags=
         -X github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil.buildVersion=${version}
         -X github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil.buildName=${pname}
         -s -w
  '';

  meta = with lib; {
    description = "An experiment in scalable routing as an encrypted IPv6 overlay network";
    homepage = "https://yggdrasil-network.github.io/";
    license = licenses.lgpl3;
    maintainers = with maintainers; [ gazally lassulus ];
  };
}

Result:

can't load package: package cmd/yggdrasil: cannot find package "." in:
        /nix/store/zvi4wy0kzh3iz7db7dl7p7dk1rqf7frj-go-1.12.6/share/go/src/cmd/yggdrasil
builder for '/nix/store/3v6yv2gf73x9avw5j5jbmg3iksvwci0x-yggdrasil-0.3.5.drv' failed with exit code 1
error: build of '/nix/store/3v6yv2gf73x9avw5j5jbmg3iksvwci0x-yggdrasil-0.3.5.drv' failed

Notes:

If you reverse the order of the subPackages then the error message will refer to cmd/yggdrasilctl instead. If you include only one child package in subPackages, the derivation will build, and this:

subPackages = [ "./cmd/yggdrasil" "./cmd/yggdrasilctl" ];

makes the derivation build correctly.

The problem is that the echo "./$subPackages" line in getGoDirs in pkgs/development/go-modules/generic/default.nix only adds the "./" onto the first item in the list.

I'd like also to suggest a change to the description for subPackages in the manual, since I found the existing one confusing. "subPackages tells the builder which child packages to build" would be clearer than "subPackages limits the builder from building child packages that have not been listed." Also, since the value in the example for subPackages is [ "." ], it would be nice to have an additional sentence describing what that means and why you would want to use that instead of leaving subPackages unspecified.

Technical details

 - system: `"x86_64-linux"`
 - host os: `Linux 4.19.56, NixOS, 19.03.git.716e973 (Koi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.2.2`
 - channels(root): `"nixos-19.03.173009.2516c454c35"`
 - channels(gem): `"nixos-19.03.173009.2516c454c35"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

@worldofpeace
Copy link
Contributor

cc @kalbasit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants