v2.2.0 fails to compile (reproducible via Nix buildGoModule): missing wiki methods/types in forgejo-sdk #47

Closed
opened 2025-12-23 11:12:29 +00:00 by malik · 8 comments
malik commented 2025-12-23 11:12:29 +00:00 (Migrated from codeberg.org)

Hi! Thanks for the project.

I’m currently trying to package forgejo-mcp for Nix/NixOS using buildGoModule.
The build fails reproducibly with Go compile errors in the wiki operation.

Context: Nix packaging

I’m using nixpkgs buildGoModule (pinned dependencies via vendorHash). This makes the build environment “clean” and reproducible.

Nix derivation:

{
  lib,
  buildGoModule,
  fetchFromGitea,
  nix-update-script,
}:

buildGoModule rec {
  pname = "forgejo-mcp";
  version = "2.2.0";

  src = fetchFromGitea {
    domain = "codeberg.org";
    owner = "goern";
    repo = "forgejo-mcp";
    rev = "v${version}";
    hash = "sha256-/FUb15b6gFANkm1DTvNRv43hUn/MGpexIpLjv7kz72I=";
  };

  vendorHash = "sha256-tOTRbc735TrIZ7fL9EywKLLlePKWMMCeuhbQJGHUuk4=";

  ldflags = [
    "-s"
    "-w"
  ];

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "This Model Context Protocol (MCP) server provides tools and resources for interacting with the Forgejo (specifically Codeberg.org) REST API";
    homepage = "https://codeberg.org/goern/forgejo-mcp";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ malik ];
    mainProgram = "forgejo-mcp";
  };
}

Reproduction

  • nix build (NixOS / Linux x86_64)
  • Alternatively I believe this corresponds to go build ./... in a clean environment.

Build log excerpt

Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/v8cr5m3i13kcgkd1z4w0papsp4zd4101-source
source root is source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Building subPackage .
Building subPackage ./cmd
Building subPackage ./operation
Building subPackage ./operation/issue
Building subPackage ./operation/pull
Building subPackage ./operation/repo
Building subPackage ./operation/search
Building subPackage ./operation/user
Building subPackage ./operation/version
Building subPackage ./operation/wiki
# forgejo.org/forgejo/forgejo-mcp/operation/wiki
operation/wiki/wiki.go:63:40: forgejo.Client().ListWikiPages undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method ListWikiPages)
operation/wiki/wiki.go:83:21: undefined: forgejo_sdk.CreateWikiPageOption
operation/wiki/wiki.go:89:39: forgejo.Client().CreateWikiPage undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method CreateWikiPage)
operation/wiki/wiki.go:115:21: undefined: forgejo_sdk.EditWikiPageOption
operation/wiki/wiki.go:121:39: forgejo.Client().EditWikiPage undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method EditWikiPage)

Expected

forgejo-mcp builds successfully from the v2.2.0 tag.

Suspected cause

It looks like the wiki implementation expects forgejo-sdk to expose wiki methods/types that are not present in:
codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2.

Do you have a recommended forgejo-sdk version / replace directive for this, or should wiki be implemented via custom HTTP calls instead of the SDK?

Hi! Thanks for the project. I’m currently trying to package forgejo-mcp for Nix/NixOS using buildGoModule. The build fails reproducibly with Go compile errors in the wiki operation. ## Context: Nix packaging I’m using nixpkgs buildGoModule (pinned dependencies via vendorHash). This makes the build environment “clean” and reproducible. Nix derivation: ```nix { lib, buildGoModule, fetchFromGitea, nix-update-script, }: buildGoModule rec { pname = "forgejo-mcp"; version = "2.2.0"; src = fetchFromGitea { domain = "codeberg.org"; owner = "goern"; repo = "forgejo-mcp"; rev = "v${version}"; hash = "sha256-/FUb15b6gFANkm1DTvNRv43hUn/MGpexIpLjv7kz72I="; }; vendorHash = "sha256-tOTRbc735TrIZ7fL9EywKLLlePKWMMCeuhbQJGHUuk4="; ldflags = [ "-s" "-w" ]; passthru.updateScript = nix-update-script { }; meta = { description = "This Model Context Protocol (MCP) server provides tools and resources for interacting with the Forgejo (specifically Codeberg.org) REST API"; homepage = "https://codeberg.org/goern/forgejo-mcp"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ malik ]; mainProgram = "forgejo-mcp"; }; } ``` ## Reproduction - `nix build` (NixOS / Linux x86_64) - Alternatively I believe this corresponds to `go build ./...` in a clean environment. ## Build log excerpt ```log Running phase: unpackPhase @nix { "action": "setPhase", "phase": "unpackPhase" } unpacking source archive /nix/store/v8cr5m3i13kcgkd1z4w0papsp4zd4101-source source root is source Running phase: patchPhase @nix { "action": "setPhase", "phase": "patchPhase" } Running phase: updateAutotoolsGnuConfigScriptsPhase @nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" } Running phase: configurePhase @nix { "action": "setPhase", "phase": "configurePhase" } Running phase: buildPhase @nix { "action": "setPhase", "phase": "buildPhase" } Building subPackage . Building subPackage ./cmd Building subPackage ./operation Building subPackage ./operation/issue Building subPackage ./operation/pull Building subPackage ./operation/repo Building subPackage ./operation/search Building subPackage ./operation/user Building subPackage ./operation/version Building subPackage ./operation/wiki # forgejo.org/forgejo/forgejo-mcp/operation/wiki operation/wiki/wiki.go:63:40: forgejo.Client().ListWikiPages undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method ListWikiPages) operation/wiki/wiki.go:83:21: undefined: forgejo_sdk.CreateWikiPageOption operation/wiki/wiki.go:89:39: forgejo.Client().CreateWikiPage undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method CreateWikiPage) operation/wiki/wiki.go:115:21: undefined: forgejo_sdk.EditWikiPageOption operation/wiki/wiki.go:121:39: forgejo.Client().EditWikiPage undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method EditWikiPage) ``` ## Expected forgejo-mcp builds successfully from the v2.2.0 tag. ## Suspected cause It looks like the wiki implementation expects forgejo-sdk to expose wiki methods/types that are not present in: `codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2`. Do you have a recommended forgejo-sdk version / replace directive for this, or should wiki be implemented via custom HTTP calls instead of the SDK?
goern commented 2025-12-23 16:00:36 +00:00 (Migrated from codeberg.org)

I’ll have a look at it in the coming days. Thanks for reporting!

I’ll have a look at it in the coming days. Thanks for reporting!
goern commented 2025-12-29 10:38:14 +00:00 (Migrated from codeberg.org)

@malik I have released https://codeberg.org/goern/forgejo-mcp/src/tag/v2.3.0 please try it out.
feel free to open this issue again if it does not work as expected.

@malik I have released https://codeberg.org/goern/forgejo-mcp/src/tag/v2.3.0 please try it out. feel free to open this issue again if it does not work as expected.
malik commented 2025-12-29 23:15:51 +00:00 (Migrated from codeberg.org)

The changes have not fixed it. The package definition now looks like this:

{
  lib,
  buildGoModule,
  fetchFromGitea,
  nix-update-script,
}:

buildGoModule rec {
  pname = "forgejo-mcp";
  version = "2.4.1";

  src = fetchFromGitea {
    domain = "codeberg.org";
    owner = "goern";
    repo = "forgejo-mcp";
    rev = "v${version}";
    hash = "sha256-kFNLDmrDr5zvk2NhD4IuX2xgbF7w7jNCOJHuGOtlB1Y=";
  };

  vendorHash = "sha256-tOTRbc735TrIZ7fL9EywKLLlePKWMMCeuhbQJGHUuk4=";

  ldflags = [
    "-s"
    "-w"
  ];

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "This Model Context Protocol (MCP) server provides tools and resources for interacting with the Forgejo (specifically Codeberg.org) REST API";
    homepage = "https://codeberg.org/goern/forgejo-mcp";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ malik ];
    mainProgram = "forgejo-mcp";
  };
}

And the logs like this:

Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/g33m7p17b4hlnnqxpqda7m922swq01gw-source
source root is source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Building subPackage .
Building subPackage ./cmd
Building subPackage ./operation
Building subPackage ./operation/issue
Building subPackage ./operation/params
Building subPackage ./operation/pull
Building subPackage ./operation/repo
Building subPackage ./operation/search
Building subPackage ./operation/user
Building subPackage ./operation/version
Building subPackage ./operation/wiki
# codeberg.org/goern/forgejo-mcp/v2/operation/wiki
operation/wiki/wiki.go:64:40: forgejo.Client().ListWikiPages undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method ListWikiPages)
operation/wiki/wiki.go:84:21: undefined: forgejo_sdk.CreateWikiPageOption
operation/wiki/wiki.go:90:39: forgejo.Client().CreateWikiPage undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method CreateWikiPage)
operation/wiki/wiki.go:116:21: undefined: forgejo_sdk.EditWikiPageOption
operation/wiki/wiki.go:122:39: forgejo.Client().EditWikiPage undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method EditWikiPage)
The [changes](https://codeberg.org/goern/forgejo-mcp/compare/v2.2.0...v2.4.1) have not fixed it. The package definition now looks like this: ```nix { lib, buildGoModule, fetchFromGitea, nix-update-script, }: buildGoModule rec { pname = "forgejo-mcp"; version = "2.4.1"; src = fetchFromGitea { domain = "codeberg.org"; owner = "goern"; repo = "forgejo-mcp"; rev = "v${version}"; hash = "sha256-kFNLDmrDr5zvk2NhD4IuX2xgbF7w7jNCOJHuGOtlB1Y="; }; vendorHash = "sha256-tOTRbc735TrIZ7fL9EywKLLlePKWMMCeuhbQJGHUuk4="; ldflags = [ "-s" "-w" ]; passthru.updateScript = nix-update-script { }; meta = { description = "This Model Context Protocol (MCP) server provides tools and resources for interacting with the Forgejo (specifically Codeberg.org) REST API"; homepage = "https://codeberg.org/goern/forgejo-mcp"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ malik ]; mainProgram = "forgejo-mcp"; }; } ``` And the logs like this: ``` Running phase: unpackPhase @nix { "action": "setPhase", "phase": "unpackPhase" } unpacking source archive /nix/store/g33m7p17b4hlnnqxpqda7m922swq01gw-source source root is source Running phase: patchPhase @nix { "action": "setPhase", "phase": "patchPhase" } Running phase: updateAutotoolsGnuConfigScriptsPhase @nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" } Running phase: configurePhase @nix { "action": "setPhase", "phase": "configurePhase" } Running phase: buildPhase @nix { "action": "setPhase", "phase": "buildPhase" } Building subPackage . Building subPackage ./cmd Building subPackage ./operation Building subPackage ./operation/issue Building subPackage ./operation/params Building subPackage ./operation/pull Building subPackage ./operation/repo Building subPackage ./operation/search Building subPackage ./operation/user Building subPackage ./operation/version Building subPackage ./operation/wiki # codeberg.org/goern/forgejo-mcp/v2/operation/wiki operation/wiki/wiki.go:64:40: forgejo.Client().ListWikiPages undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method ListWikiPages) operation/wiki/wiki.go:84:21: undefined: forgejo_sdk.CreateWikiPageOption operation/wiki/wiki.go:90:39: forgejo.Client().CreateWikiPage undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method CreateWikiPage) operation/wiki/wiki.go:116:21: undefined: forgejo_sdk.EditWikiPageOption operation/wiki/wiki.go:122:39: forgejo.Client().EditWikiPage undefined (type *"codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2".Client has no field or method EditWikiPage) ```
byteflavour commented 2025-12-30 02:09:54 +00:00 (Migrated from codeberg.org)

I remember i had (maybe) the same problem.
My tip: The Go tool chain tries to update the packages (dependencies) and this does not work because as i understand it the nix build env for it's sake of reproducibility is prohibiting inbound impact (in process updates).

You can check my build solution here: a flake of this mcps

ldflags = [
            "-s"
            "-w"
            "-X main.Version=${version}"
          ];
          subPackages = [ "." ];
          env.CGO_ENABLED = "0";
          env.GOTOOLCHAIN = "local";

For me as a not very experienced user of nix(os) and go-lang my digging went like that:
I was able to build the repo manually (mutable) so the repo is fine.
I double checked that while changing the linking order of dependencies and got clear that all dependencies weren't working in the build env.

I have not debugged it completely but forcing the build env to act only local and with the given dependencies was doing the trick for me.

I hope that works for you @malik

I remember i had (maybe) the same problem. My tip: The Go tool chain tries to update the packages (dependencies) and this does not work because as i understand it the nix build env for it's sake of reproducibility is prohibiting inbound impact (in process updates). You can check my build solution here: [a flake of this mcps](https://codeberg.org/byteflavour/goern-forgejo-mcp-flake/src/branch/main/flake.nix) ```nix ldflags = [ "-s" "-w" "-X main.Version=${version}" ]; subPackages = [ "." ]; env.CGO_ENABLED = "0"; env.GOTOOLCHAIN = "local"; ``` For me as a not very experienced user of nix(os) and go-lang my digging went like that: I was able to build the repo manually (mutable) so the repo is fine. I double checked that while changing the linking order of dependencies and got clear that all dependencies weren't working in the build env. I have not debugged it completely but forcing the build env to act only local and with the given dependencies was doing the trick for me. I hope that works for you @malik
goern commented 2025-12-30 10:45:17 +00:00 (Migrated from codeberg.org)

@byteflavour is there something I can do on my side to test/make sure that it will work on nix?

@byteflavour is there something I can do on my side to test/make sure that it will work on nix?
goern commented 2025-12-30 11:02:43 +00:00 (Migrated from codeberg.org)

@byteflavour @malik Thanks for the analysis and the working flake example!

The root cause is that operation/wiki/wiki.go uses forgejo-sdk methods that don't exist yet in the released SDK (v2.0.0). The wiki tools were never actually registered/enabled, but the code still gets compiled when running go build ./....

I've added a Go build tag to exclude the wiki package from default builds:

//go:build wiki

This means:

  • Default builds (go build ./...) now skip the wiki package entirely
  • Nix builds should work without needing subPackages = [ "." ]
  • The wiki code is preserved for when upstream forgejo-sdk adds wiki API support

This fix will be in the next release. In the meantime, the workaround with subPackages = [ "." ] and env.GOTOOLCHAIN = "local" continues to work.

See docs/plans/wiki-support.md for the upstream contribution plan to add wiki methods to forgejo-sdk.

@byteflavour @malik Thanks for the analysis and the working flake example! The root cause is that `operation/wiki/wiki.go` uses forgejo-sdk methods that don't exist yet in the released SDK (v2.0.0). The wiki tools were never actually registered/enabled, but the code still gets compiled when running `go build ./...`. I've added a Go build tag to exclude the wiki package from default builds: ```go //go:build wiki ``` This means: - **Default builds** (`go build ./...`) now skip the wiki package entirely - **Nix builds** should work without needing `subPackages = [ "." ]` - The wiki code is preserved for when upstream forgejo-sdk adds wiki API support This fix will be in the next release. In the meantime, the workaround with `subPackages = [ "." ]` and `env.GOTOOLCHAIN = "local"` continues to work. See `docs/plans/wiki-support.md` for the upstream contribution plan to add wiki methods to forgejo-sdk.
goern commented 2025-12-30 11:06:09 +00:00 (Migrated from codeberg.org)

@malik let me know if codeberg.org/goern/forgejo-mcp@7b7536a10d helps

@malik let me know if https://codeberg.org/goern/forgejo-mcp/commit/7b7536a10d813cc9fac126b80b30508c1bf72d05 helps
malik commented 2025-12-30 11:26:52 +00:00 (Migrated from codeberg.org)

Thanks for your work, the issue is fixed

Thanks for your work, the issue is fixed
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
agentic-forges/forgejo-mcp#47
No description provided.