Unable to Compile Go Code with SQLite Dependencies in Nix Flake Shell

I have a simple Nix Flake shell with the SQLite dependencies required to access the database, but I am unable to compile the code due to the following error:

go build -o ocean-market cmd/main.go
# runtime/cgo
flag provided but not defined: -E
Go is a tool for managing Go source code.

Usage:

	go <command> [arguments]

my nix flake is

{
  description = "PoC";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";

    gomod2nix = {
      url = "github:tweag/gomod2nix";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.utils.follows = "utils";
    };
  };

  outputs = { self, nixpkgs, flake-utils, gomod2nix }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ gomod2nix.overlays.default ];
        };
      in
      {
        packages = {
          default = pkgs.gnumake;
        };
        formatter = pkgs.nixpkgs-fmt;

        devShell = pkgs.mkShell {
          buildInputs = with pkgs; [
            gnumake
            gcc
            glibc.dev

            go
            gopls
            gotools
            go-tools
            gomod2nix.packages.${system}.default
            golangci-lint
            protobuf3_20
          ];
          buildPhase = "make";
          shellHook = ''
            export CGO_ENABLED=1

            export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
            make dep
          '';
        };
      }
    );
}

What does which go return inside the shell?

[vincent@vincenzopalazzo-arch-dev]$ which go
/bin/go

I think this is wrong right? I need to set any env variable?

However, nothing change with the following diff

--- a/flake.nix
+++ b/flake.nix
@@ -43,8 +43,9 @@
           buildPhase = "make";
           shellHook = ''
             export CGO_ENABLED=1
+            # Ensure the Go binary from Nix is used
+            export PATH=${pkgs.go}/bin:$PATH

-            export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
             make dep
           '';
         };

You shouldn’t need to do any of this. nix develop (and other nix commands) prepend your PATH with the store locations of your various packages. Most likely $GOROOT is not set inside the dev shell so your PATH ends up being prepended with just /bin.

I’m also confused by the error message. There was no -E flag passed to your command, yet the error complains about that flag. I initially thought that you had it set in a shell alias for the go command, but it is visibly not the case.

IDK I am just using the sqllite library and I think this is the library that use the flag, so I have no idea on how to fix this