GuixのSubstituteサーバーを設定する

2024/12/18に公開

デフォルトのSubstituteサーバーを使っていたところ、私の環境では通信速度が遅く不便でした。そこで上海交通大学が提供してくれているミラーサーバーを設定してみたら早くなったので、その方法を紹介します。

一時的にSubstituteサーバーを使う

--substitute-urlsオプションを使うことで、設定されているものとは別のSubstituteサーバーを一時的に使うことができます。速度を調べてみたいときなどに便利です。

guix intall パッケージ名 --substitute-urls="https://mirror.sjtu.edu.cn/guix/"

Guix Systemの場合

%desktop-serviceを使っていた場合は%base-serviceの部分を%desktop-serviceに変更してください。

(operating-system
...
 (services
  (append
   (modify-services %base-service
                     (guix-service-type config =>
                                       (guix-configuration
                                        (inherit config)
                                        (substitute-urls
                                         (append
                                          (list "https://mirror.sjtu.edu.cn/guix")
                                          %default-substitute-urls)))))
   (list
    (service ...

その他のディストリビューションの場合

試していませんが、guix-daemon.serviceを以下のようにするとできるらしいです。

guix-daemon.service
ExecStart=/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon --build-users-group=guixbuild --substitute-urls="https://mirror.sjtu.edu.cn/guix/"

リンク

他にも有志によるミラーサーバーがいくつかあるようです。
https://github.com/franzos/awesome-guix?tab=readme-ov-file#build-server
https://libreplanet.org/wiki/Group:Guix/Mirrors

参考
https://mirrors.sjtug.sjtu.edu.cn/docs/guix
https://guix.gnu.org/manual/en/html_node/Getting-Substitutes-from-Other-Servers.html

Discussion