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 ブラウザでは UI の一部が表示されないため、Nix パッケージを試して、UX がより使いやすくなるかを確認しようとしました。

Nix を介した単純なダウンロード/ビルドを試みましたが、前述のエラーが発生しました。

興味深いですね。このパッケージは公式に Discourse によって提供されているものではないと見ています。メンテナーの一覧をざっと見ましたが、私が知る限り Discourse チームのメンバーは記載されていません。また、AFAIK(私の知る限り)では、これに関する#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` は、指定されたパッケージ(`-p`)がシステム上で利用可能になるシェルを起動します。シェルを閉じると、それらのパッケージはインストールされなくなります

このスレッドがロックされているかどうかを確認するためにテストしています。最近の編集の一つが表示されないからです。

おそらく、編集が承認されて初めて投稿に表示されるのでしょう

スレッドはロックされておらず、私たちはこのトピックを楽しみ、学んでいます。ご協力いただきありがとうございます。Metaへようこそ :+1: