Skip to content

Instantly share code, notes, and snippets.

@kenz-gelsoft
Last active June 8, 2024 15:23
Show Gist options
  • Save kenz-gelsoft/fd009699febc197738cc3f8cee0cbcf3 to your computer and use it in GitHub Desktop.
Save kenz-gelsoft/fd009699febc197738cc3f8cee0cbcf3 to your computer and use it in GitHub Desktop.
ArchLinux on IdeaPad Duet

ArchLinux on IdeaPad Duet Chromebook

Screenshot 2022-05-01 10 59 20

経緯

  • ChromeOS を Stable Channel 以外に変更していると、ChromeOS アップデートごとにちょくちょく他 Distro をインストールした Container が破損していた。
  • 仕方ないので testing あたりまでパッケージだけ更新して Debian のままなんとか使っていた。
  • どうやら Stable Channel ではそのようなコンテナの破損は見られないということで、 ChromeOS を Stable Channel に戻した上で、ArchLinux を再びインストールすることにした。

ArchLinux の IdeaPad Duet Chromebook へのインストール

基本的には下記ページの手順に従ってインストールした。このページではハマった点、アレンジした点をメモしている。

3. Setting up networking

  • 下記の手順が一見不要なように見えたが、この手順を飛ばしていたせいで、ChromeOS Terminalから接続できない状態となった。
    ip -4 a show dev eth0
    # ^ See if there's a network connection.
    #   non-empty output = good (skip)
    #   empty output     = proceed below
    
    dhcpcd eth0
    ping 8.8.8.8
    # ^ Connects to the internet. It if works, ping should
    #   start giving some results.
    #
    # > dhcpcd-9.4.0 starting
    #   ...
    #   forked in background, child pid 122
    #
    # > 64 bytes from 8.8.8.8: icmp_seq=1 ttl=53 time=27.6ms
    #   ...
    
    pacman -Syu dhclient
    systemctl enable --now dhclient@eth0
    # ^ use dhclient to auto-connect eth0 on startup
    

5. Install yay

  • AUR で cros-container-guest-tools をインストールするために、AUR ヘルパーとして yay をインストールすることを案内している。
  • yay は Go 言語で書かれているが、 yay の作者の一人が別に作り始めた paru を使うことにした。
  • paru は Rust で書かれていて、なおかつ yay や pacman と親和性のあるコマンドラインとなっている。

6. Install cros-container-guest-tools

  • ここでは mousepad という GUI テキストエディタをテスト用にインストールしている。
  • gvim がここまででインストールされていたので、 mousepad はインストールしなかった。

日本語環境の構築

基本的には 地域化 - ArchWiki の記載に従った。

  • TTF Font としては Noto Sans を入れていたので、ここで紹介されているフォントは入れず。
    • Firefox をインストールしようとしたら必要になってこの設定までにインストール済みだった。

日本語入力システム

インプットメソッド としては、 ibus-mozc を使いたかった。 paru で bazel 依存関係がビルドエラーになるためにインストールできなかった。

  • 以下から選べるのだが、-bin なしの各パッケージを選んでいっても素直にビルドが通るものがなかった。

    bazel (bazel-git, bazel024-bin, bazel024, bazel2, bazel3, bazel3-bin, bazel31, bazel31-bin, bazelisk, bazelisk-bin) (make)

fcitx

  • 仕方ないので fcitx-mozc をインストールした。
  • 環境変数の設定
    [kenz@arch ~]$ cat ~/.pam_environment 
    GTK_IM_MODULE DEFAULT=fcitx
    QT_IM_MODULE  DEFAULT=fcitx
    XMODIFIERS    DEFAULT=@im=fcitx
    
  • 自動起動の設定
    • 以下の方法、だめでした:
      [kenz@arch ~]$ mkdir .config/autostart
      [kenz@arch ~]$ cp /etc/xdg/autostart/fcitx-autostart.desktop .config/autostart/
      
  • fcitx-configtool をインストールして、フォント(Noto Sans CJK JP Regular 12px)・スキン(dark)あたりを設定。
  • Firefox を MOZ_ENABLE_WAYLAND=1 で起動すると、fcitx での日本語入力がまったくまともに動作しない。
    • ibus-mozc ではちゃんと動いていた気がするので、ここは改善したいところ。
  • fcitx5 を使えという記述を見たので、もう一度 ibus を試してから fcitx5 を試す。

ibus(再)

  • ibus-mozc は、ビルドのために bazel.build に依存しているが、 bazel-bootstrap のビルドが std::numeric_limit だかの定義が解決できずに失敗しまくっていた。
  • たぶんこれは、どれかのソースファイルに #include <limits> を足すことでも解決できるが、より楽な解として、バイナリ AUR である bazel3-bin を取ってきて下記のようにやっつけることで対処できた:
    [kenz@arch bazel3-bin]$ git diff
    diff --git a/PKGBUILD b/PKGBUILD
    index e29ea13..bb3407e 100644
    --- a/PKGBUILD
    +++ b/PKGBUILD
    @@ -3,7 +3,7 @@ pkgname=bazel3-bin
     pkgver=3.7.2
     pkgrel=1
     pkgdesc='Build and test software of any size, quickly and reliably.'
    -arch=('x86_64')
    +arch=('aarch64')
     url='https://bazel.build'
     license=('Apache')
     depends=('java-environment=11')
    @@ -11,13 +11,13 @@ provides=("${pkgname%-bin}" "bazel=${pkgver}")
     conflicts=('bazel3' 'bazel')
     options=('!strip')
     source=(
    -    "https://github.com/bazelbuild/bazel/releases/download/${pkgver}/bazel_nojdk-${pkgver}-linux-x86_64"
    +    "https://github.com/bazelbuild/bazel/releases/download/${pkgver}/bazel-${pkgver}-linux-arm64"
     )
    -noextract=("bazel_nojdk-${pkgver}-linux-x86_64")
    +noextract=("bazel-${pkgver}-linux-arm64")
     sha256sums=(
    -    "dbf43bf909d2dbdd428820a6794d668404edcf1e15f20475837e568c83c9cd7b"
    +    "6ebd9eccbcb8f63c92a324c0c86cec11963aa9dcb914dd4718f592fdfeda9823"
     )
    
     package() {
    -    install -Dm755 bazel_nojdk-${pkgver}-linux-x86_64 "${pkgdir}/usr/bin/bazel"
    +    install -Dm755 bazel-${pkgver}-linux-arm64 "${pkgdir}/usr/bin/bazel"
     }
    • _nojdk は実行時依存関係が小さいバイナリであるようだが、arm64 のビルドがリリースされていなかった。通常のバイナリでも bazel としては機能したので上記の通りとした。
  • mozc は paru -S mozc を何回かやっているとビルド・インストールできた。
  • ibus-mozc は bazel が重すぎて gcc や bazel 自身(jvm) が頓死しまくった。下記のようにビルドの同時実行数を下げてやることで結果として無事ビルドできた。
    [kenz@arch ibus-mozc]$ git diff
    diff --git a/PKGBUILD b/PKGBUILD
    index 3fb2864..4e19064 100644
    --- a/PKGBUILD
    +++ b/PKGBUILD
    @@ -7,7 +7,7 @@ pkgname='ibus-mozc'
     pkgver=2.28.4715.102
     pkgrel=1
     pkgdesc='Mozc module for IBus'
    -arch=('x86_64')
    +arch=('x86_64' 'aarch64')
     url='https://github.com/google/mozc'
     license=('Apache' 'BSD' 'LGPL' 'custom')
     depends=('ibus>=1.4.1' 'mozc>=2.28.4715.102')
    @@ -34,7 +34,7 @@ build() {
         cd ${pkgname}-git/src
    
         export JAVA_HOME='/usr/lib/jvm/java-11-openjdk/'
    -    bazel build renderer:mozc_renderer unix/ibus:ibus_mozc unix/icons --config oss_linux --compilation_mode opt
    +    bazel build renderer:mozc_renderer unix/ibus:ibus_mozc unix/icons --config oss_linux --compilation_mode opt --jobs=4
     }
    
     package() {
  • 環境変数の設定
    [kenz@arch ibus-mozc]$ cat ~/.pam_environment 
    GTK_IM_MODULE DEFAULT=ibus
    QT_IM_MODULE  DEFAULT=ibus
    XMODIFIERS    DEFAULT=@im=ibus
    
    • ibus-setup は .bashrc にでも書いてかって言ってくるけど、fcitx のときにやったように、上記記載とした。
  • 自動起動の設定
    [kenz@arch ~]$ tail -2 ~/.bashrc 
    ibus-daemon -drx
    
    • .bashrc で ibus-daemon を立ち上げるのは、ChromeOS の App Launcher から GUI アプリを開いたときに日本語入力が動かなくて不便なので、systemd Unit にすることを試みたが、上手く行かなかったので一旦断念。
    • 下記のようなファイルを作って systemctl --user enable ibus.service してみていた。
      [kenz@arch ~]$ cat ~/.config/systemd/user/ibus.service 
      [Unit]
      Description=Intelligent Input Bus
      Documentation=man:ibus-daemon(1)
      
      [Service]
      Environment=GTK_IM_MODULE=ibus XMODIFIERS="@im=ibus" QT_IM_MODULE=ibus
      ExecStart=/usr/bin/ibus-daemon --replace --xim --panel disable
      ExecReload=/usr/bin/ibus restart
      ExecStop=/usr/bin/ibus exit
      
      [Install]
      WantedBy=default.target
      • ibus, systemd, archlinux, crostini などを混ぜて色々検索したが、2016-2017 頃の情報しか出てこなくて、最近の実装で実績のある情報は見つからなかった。
  • 状況
    • ibus-setup ではインプットメソッド間の切り替えキーバインドを定義するが、インプットメソッド自体の ON/OFF は「半角全角キー」が必要。
    • 候補ウィンドウの表示位置が hi-dpi を考慮できていない動作になっている。表示が変なだけで使えなくはないのでごまかしごまかしやっているが、解消したい。
      • こんなおもしろ記述 ibus/ibus#2221 (comment) があるから

        Reagarding to Wayland, you no longer settle the lookup window position with the IM modules since Wayland gives the permission to the window manager only. E.g. gnome-shell in GNOME Wayland so you need to export GTK_IM_MODULE="wayland" instead of "ibus" and QT applications cannot settle the window position in GNOME Wayland.

      • 以下のように設定してみたが、GTK アプリ起動時に Wayland ディスプレイが見つからないとかで死ぬ。
        • GTK_IM_MODULE=wayland
  • 「ibus-mozc!?廃止したはずでは…」
    • https://github.com/google/mozc/issues/287 で Deprecation とともに mozc の ibus クライアントコードの廃止が提案されていたが
    • https://github.com/google/mozc/commits/master/src/unix/ibus を見るに細々とメンテが継続されている。
    • Qt 実装への移行が進んでおり、Win/Mac/Unix ともに Qt GUI に統一することでメンテナンスコストを下げることで延命されるように見える。
    • GUI としての機能性は fcitx よりも高いと感じているので、ぜひとも頑張っていただきたい。

Stable Channel の ChromeOS で新スタートメニューを使用する

How to enable the new Chrome OS start menu for the Chromebook の記載に従い、下記設定を行った。

  • chrome://flags をひらく
  • Productivity Experiment: App Launcher を検索して有効にする

とりあえず、これで ChromeOS の動作として不満な部分は解消した。

@kenz-gelsoft
Copy link
Author

うーんやっぱり壊れるので欲張らずdebianコンテナで生きるかな…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment