Discourse 包在 nix-shell 中构建失败

尝试下载并构建 Discourse 的 Nix 包,但因疑似 pnpm 依赖错误而失败:

 ERR_PNPM_INVALID_DEPENDENCY_NAME  Refusing to place a dependency under /build/source/frontend/discourse-types/node_modules with the invalid alias "@types/@glimmer__component"

ERROR: pnpm failed to install dependencies

If you see ERR_PNPM_NO_OFFLINE_TARBALL above this, follow these to fix the issue:
1. Set pnpmDeps.hash to "" (empty string)
2. Build the derivation and wait for it to fail with a hash mismatch
3. Copy the 'got: sha256-' value back into the pnpmDeps.hash field

If you see ERR_PNPM_LOCKFILE_CONFIG_MISMATCH above this, try changing the pnpm version
Found 'pnpm' with version '10.34.4'

error: Cannot build '/nix/store/k90f0nxqhlyb1bym9lg5xl6pfjz4vamf-discourse-assets-2026.1.4.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/biwwabb1xl58v4ywqmmc7d4vm0sl78q3-discourse-assets-2026.1.4-node_modules
         /nix/store/jsbd94c63h63yq5xvrp27m5l1sg6667c-discourse-assets-2026.1.4-generated
         /nix/store/n278iw1v8kzswvwm8f6n6g15gkw6wb0q-discourse-assets-2026.1.4-frontend
         /nix/store/qnxglj6z2n8fn46af9rp7161634brcgk-discourse-assets-2026.1.4
       Last 25 log lines:
       > Progress: resolved 1909, reused 1263, downloaded 0, added 0
       > Progress: resolved 1909, reused 1907, downloaded 0, added 65
       > Progress: resolved 1909, reused 1909, downloaded 0, added 435
       > Progress: resolved 1909, reused 1909, downloaded 0, added 530
       > Progress: resolved 1909, reused 1909, downloaded 0, added 672
       > Progress: resolved 1909, reused 1909, downloaded 0, added 838
       > Progress: resolved 1909, reused 1909, downloaded 0, added 1036
       > Progress: resolved 1909, reused 1909, downloaded 0, added 1175
       > Progress: resolved 1909, reused 1909, downloaded 0, added 1464
       > Progress: resolved 1909, reused 1909, downloaded 0, added 1767
       > Progress: resolved 1909, reused 1909, downloaded 0, added 1907
       > Progress: resolved 1909, reused 1909, downloaded 0, added 1908
       > Progress: resolved 1909, reused 1909, downloaded 0, added 1909, done
       >  ERR_PNPM_INVALID_DEPENDENCY_NAME  Refusing to place a dependency under /build/source/frontend/discourse-types/node_modules with the invalid alias "@types/@glimmer__component"
       >
       > ERROR: pnpm failed to install dependencies
       >
       > If you see ERR_PNPM_NO_OFFLINE_TARBALL above this, follow these to fix the issue:
       > 1. Set pnpmDeps.hash to "" (empty string)
       > 2. Build the derivation and wait for it to fail with a hash mismatch
       > 3. Copy the 'got: sha256-' value back into the pnpmDeps.hash field
       >
       > If you see ERR_PNPM_LOCKFILE_CONFIG_MISMATCH above this, try changing the pnpm version
       > Found 'pnpm' with version '10.34.4'
       >
       For full logs, run:
         nix log /nix/store/k90f0nxqhlyb1bym9lg5xl6pfjz4vamf-discourse-assets-2026.1.4.drv
error: Cannot build '/nix/store/9n8grwvci4gd2c64i9wm5ggw5v4r63xf-discourse-2026.1.4.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/l9xhbd5scihfln5jr9vh1c6l4xznaall-discourse-2026.1.4
error: Build failed due to failed dependency

我好像没在别处看到过这个问题,觉得你们应该知道一下。

问题在于,仅支持 Debian/Ubuntu,不支持 Nix。这是用于开发环境还是生产环境?

这仅仅是使用 Nix 包管理器从 nixpkgs 下载 Discourse 包。派生(Derivations)的工作原理本质上是从源代码直接克隆并构建包。

我只是像安装其他任何 NixOS 包一样临时安装了一个包。这并不是专门为了开发或生产环境,实际上我只是想看看是否能在命令行界面(CLI)中使用 Discourse。我的 TUI 浏览器无法显示部分用户界面,因此我想试用一下这个 Nix 包,看看用户体验是否更友好。

尝试通过 Nix 进行简单的下载/构建时,出现了上述错误。

有意思。我认为这个包并非由 Discourse 官方发布。快速浏览一下维护者列表,并没有列出我所知道的任何 Discourse 团队成员。此外,据我所知,也没有关于此的 #documentation。

供参考:我想是 这个插件

啊,是的,那是 nixpkg 的维护者

实际的源代码位于 let in 块中

第 55 行:

let
  version = "2026.1.4";

  src = fetchFromGitHub {
    owner = "discourse";
    repo = "discourse";
    rev = "v${version}";
    sha256 = "sha256-kQYDKZIMsWByuCZQfUlwhoIew5QykVylRMh6xvrHIBY=";
  };
in
# ...

所以它从 discourse/discourse 获取源码,其余的派生过程基本上只是构建步骤,包括文件放置位置、如何处理某些构建错误等

这个 src 参数有点像变量,因为它会向下传递到派生过程的其余部分

因此,你无需完全切换到 NixOS 即可测试此功能

Nix 包管理器几乎适用于任何机器

nix-shell -p discourse

其中 nix-shell 会启动一个 Shell 环境,在该环境中,通过 -p 指定的包即可在系统上使用。一旦关闭该 Shell,这些包便不再安装。

测试一下这个帖子是否已被锁定,因为我看不到我最近的一次编辑。

也许编辑需要审核通过后才会显示在帖子中

该帖子并未锁定,我们正在享受这个话题并从中学习。感谢您的贡献,欢迎来到 Meta :+1: