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

nix build hangs on Building subPackage . #118

Open
marcuswhybrow opened this issue Apr 19, 2023 · 1 comment
Open

nix build hangs on Building subPackage . #118

marcuswhybrow opened this issue Apr 19, 2023 · 1 comment

Comments

@marcuswhybrow
Copy link

marcuswhybrow commented Apr 19, 2023

Hello, it's my first time using gomod2nix. My flake builds my hello world main.go, but always hangs for 8 seconds at Building subPackage . It hangs for much longer on a real project I'm attempting to transition. It feels like a setup cost I should be paying once, which is then cached, but it's happening on every code change. Am I doing something wrong?

❯ ls
flake.lock  flake.nix  go.mod  gomod2nix.toml main.go

❯ cat go.mod
module github.com/marcuswhybrow/myproject

go 1.20

❯ cat gomod2nix.toml
schema = 3

[mod]

❯ nix build  --verbose --log-format bar-with-logs
this derivation will be built:
  /nix/store/pw50p05dxlnnz16j7a9dvq1p29gcr7q0-myproject.drv
building '/nix/store/pw50p05dxlnnz16j7a9dvq1p29gcr7q0-myproject.drv'...
myproject> unpacking sources
myproject> unpacking source archive /nix/store/wycclwg1dgyrhx4j0z6w94ch707cdc8j-golang
myproject> source root is golang
myproject> patching sources
myproject> configuring
myproject> building
myproject> Building subPackage .        <-- Hangs here for 8 seconds
myproject> internal/goarch
myproject> internal/unsafeheader
myproject> internal/abi
myproject> internal/cpu
myproject> internal/bytealg
...

My flake.nix is dead simple...

{
  description = "Static Site Generator written in Golang";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  inputs.flake-utils.url = "github:numtide/flake-utils";
  inputs.gomod2nix.url = "github:nix-community/gomod2nix";

  outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: let
    pkgs = import inputs.nixpkgs {
      inherit system;
      overlays = [ inputs.gomod2nix.overlays.default ];
    };
  in {
    packages.default = pkgs.buildGoApplication {
      name = "myproject";
      pwd = ./.;
      src = ./.;
      modules = ./gomod2nix.toml;
    };

    devShells.default = pkgs.mkShell {
      name = "myproject";
      packages = [
        (pkgs.mkGoEnv { pwd = ./.; })
        pkgs.gomod2nix
      ];
    };
  });
}

I think these lines are the source of my troubles...

for pkg in $(getGoDirs ""); do
echo "Building subPackage $pkg"
buildGoDir install "$pkg"
done

Thanks for any suggestions.

marcuswhybrow added a commit to marcuswhybrow/ssg-fight that referenced this issue Apr 19, 2023
Currently gomox2nix takes an annoyingly good while to build.
See nix-community/gomod2nix#118 for details
@peterldowns
Copy link

I've also noticed the same thing. Despite the claim that each dependency is cached, building with gomod2nix is noticeably longer than building with the nixpkgs "buildGoModule". I've switched back to that.

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

No branches or pull requests

2 participants