I’m trying to build tdfgo and a submodule is giving me difficulty.
This build definition seems close. The submodule builds correctly (I think), but can anyone help me with the intermediate step between building the submodule and building tdfgo?
let
pkgs = import <nixpkgs> {};
pname = "tdfgo";
src = pkgs.fetchFromGitHub {
owner = "digitallyserviced";
repo = pname;
rev = "05c13c303c55217294746e3b11aa3f4d9f453904";
sha256 = "sha256-CvSH/WkGP2PTjf+pO6WCfmg3AQOCSG999OnSSuYKq1Q=";
};
in with pkgs;
buildGo118Module {
inherit src;
name = pname;
coloredcobra = buildGo118Module {
inherit src;
name = "coloredcobra";
vendorSha256 = "sha256-jiKrmR3zwpdHy5k0tOd7xBnxzwLaxYl1k6dYPfT8ao4=";
modRoot = "./pkg/coloredcobra";
# maybe a postBuild step should go here?
};
# maybe a preConfigure step should go here?
vendorSha256 = "sha256-Ir+h6e4dFDC0QQ48txZl+S903+VMHpDV9ALJQ4gvDnI=";
}
I also tried the method in this reddit discussion, but it appeared to only build the submodule.
That line tells go to replace the github.com/ivanpirog/coloredcobra dependency with the contents in ./pkg/coloredcobra. If we are building in a source directory like buildGoModule is doing than this needs no extra handling and just works.
If we are building in a source directory like buildGoModule is doing than this needs no extra handling and just works.
Ideally, you are correct. Perhaps you could show me how?
With what steps do you exactly need help?
I’ll attempt to clarify. Would you agree that, with the default.nix posted in the OP, it’s building the coloredcobra submodule according to the go.mod rules?
It errors. I googled a bit and found other people with the same issue - it seems that sometimes submodule builds have to be executed from inside the submodule directory, or else the build errors as it’s doing here. I found that explanation here, a thread I linked to in the OP.
Building subPackage ./cmd
Building subPackage ./pkg/coloredcobra
main module (github.com/digitallyserviced/tdfgo) does not contain package github.com/digitallyserviced/tdfgo/pkg/coloredcobra
error: builder for '/nix/store/m9wk6hl0rqjc116gx8r9vvsl9lkzw0i5-tdfgo.drv' failed with exit code 1;
last 10 log lines:
> github.com/spf13/cobra/doc
> net/http/httptrace
> net/http
> github.com/gookit/goutil/fsutil
> github.com/digitallyserviced/tdfgo/tdf
> github.com/digitallyserviced/tdfgo/cmd
> github.com/digitallyserviced/tdfgo
> Building subPackage ./cmd
> Building subPackage ./pkg/coloredcobra
> main module (github.com/digitallyserviced/tdfgo) does not contain package github.com/digitallyserviced/tdfgo/pkg/coloredcobra
For full logs, run 'nix log /nix/store/m9wk6hl0rqjc116gx8r9vvsl9lkzw0i5-tdfgo.drv'.
One way around that might be to build the submodule separately, and use that prebuilt submodule in the root project. That is what I am attempting to work out here.