Skip to content

Blog

Asahi Linux のアンインストール

MacBook M2 Pro に入れた Asahi を消すぞよ!インストールより怖いぞよ!

調査

diskutil結果とその結果をもとに消すべきパーティションについてのやり取りが書かれています。

文鎮化するので絶対に消してはいけないパーティションと、Mac側の領域を戻すために消さない方が良いパーティションがわかります。

In disk0, you should delete partitions 3, 4, 5 and 6 to fully remove the Linux installation, and extend 2 to take up the newly-freed space.

3 contains the Apple specific stuff and u-boot. 4 is the Linux ESP, containing Grub. 5 and 6 are Linux partitions, with 6 being the root partition and 5 being one of a few possibilities (/boot or perhaps a swap partition; does it really matter though?).

Partitions you should never remove under any circumstance (and it won’t let you): 1 and 7. Removing those can brick your Mac to the point of requiring a separate one with Apple Configurator to recreate. Don’t touch them.

Partitions you most likely shouldn’t remove: 2. It’s your normal macOS installation.

直接実行するのは怖いので中身を確認します。前半は上のredditに書かれているコマンドと実質同じですね。後半は少々違くて、パーティションのuuidをいじっている?ようです。

正しいのかもしれませんが、今回はこのスクリプトを使うのはやめて手動でやろうと思います。

実践

まずは現状の確認です。

Terminal window
diskutil list

出力:

/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: Apple_APFS_ISC Container disk1 524.3 MB disk0s1
2: Apple_APFS Container disk4 700.0 GB disk0s2
3: Apple_APFS Container disk3 2.5 GB disk0s3
4: EFI EFI - ASAHI 524.3 MB disk0s4
5: Linux Filesystem 1.1 GB disk0s5
6: Linux Filesystem 290.6 GB disk0s6
7: Apple_APFS_Recovery Container disk2 5.4 GB disk0s7
/dev/disk3 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +2.5 GB disk3
Physical Store disk0s3
1: APFS Volume Asahi Linux - Data 2.2 MB disk3s1
2: APFS Volume Asahi Linux 1.1 MB disk3s2
3: APFS Volume Preboot 195.6 MB disk3s3
4: APFS Volume Recovery 808.2 MB disk3s4
/dev/disk4 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +700.0 GB disk4
Physical Store disk0s2
1: APFS Volume Macintosh HD 11.2 GB disk4s1
2: APFS Snapshot com.apple.os.update-... 11.2 GB disk4s1s1
3: APFS Volume Preboot 7.1 GB disk4s2
4: APFS Volume Recovery 1.0 GB disk4s3
5: APFS Volume Macintosh HD - Data 194.5 GB disk4s5
6: APFS Volume VM 20.5 KB disk4s6
7: APFS Volume Nix Store 79.7 GB disk4s7
/dev/disk5 (disk image):
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme +3.2 GB disk5
1: Apple_partition_map 32.3 KB disk5s1
2: Apple_HFS Affinity Photo 2 3.2 GB disk5s2

Affinity Photo 2 がいるのはちょっとよくわからないので、後で調べましょう。今回は関係ないはずです。

上のRedditと相違ないようです。以下の順にコマンドを打ちました。

Terminal window
diskutil apfs deleteContainer disk0s3
diskutil eraseVolume free none /dev/disk0s4
diskutil eraseVolume free none /dev/disk0s5
diskutil eraseVolume free none /dev/disk0s6
diskutil apfs resizeContainer /dev/disk0s2 0

無事 Asahi Linux のパーティションは消え、Mac のユーザー領域も戻ってきました。

まとめ

めでたしめでたしなのです!

NixOSインストール時のエラーについて

エラーに遭遇したぞよ。

エラー内容

NixOSインストール直後(非ライブ環境)にて、dotfilesを落としてきてビルドしようとしたところ、 error: path '*******-linux-zen-6.14.**-modules-shrunk/lib' is not in the Nix store というようなエラーがでました。

解決策

ここに載っていました。たぶんnixバイナリかデーモンが古かったためかと思われます。

サイトではshell.nixを用意するのがSolutionとなっていましたが、私の場合以下のコマンドでも解決しました。

Terminal window
nix shell github:NixOS/nixpkgs/nixpkgs-unstable#{nix,nixos-rebuild}

まとめ

isoは新しいものを使うべきぞよ!

画面の明さを自動調整したかった

wluma というパッケージがあるらしいぞよ。home-manager のオプションも提供されているのでこれで設定を書いていきます。

{ ... }: {
services.wluma = {
enable = true;
settings = {
"output.backlight" = {
name = "eDP-1";
path = "/sys/class/backlight/amdgpu_bl1/brightness";
capturer = "wayland";
};
};
systemd.enable = true;
systemd.target = "graphical-session.target";
};
}

これでビルド仕直したらデーモンはちゃんと起動したが、systemctl --user status wluma.service の出力はこれ。

○ wluma.service - Automatic brightness adjustment based on screen contents and ALS
Loaded: loaded (/home/ojii3/.config/systemd/user/wluma.service; enabled; preset: ignored)
Active: inactive (dead)
Apr 14 10:54:50 Komachan wluma[31285]: [2025-04-14T01:54:50Z INFO wluma] Continue adjusting brightness and wluma will learn your preference over time.
Apr 14 10:54:50 Komachan wluma[31285]: thread 'als' panicked at src/main.rs:131:26:
Apr 14 10:54:50 Komachan wluma[31285]: Unable to initialize ALS IIO sensor: "No iio device found"
Apr 14 10:54:50 Komachan wluma[31285]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Apr 14 10:54:50 Komachan systemd[2127]: wluma.service: Main process exited, code=exited, status=1/FAILURE
Apr 14 10:54:50 Komachan systemd[2127]: wluma.service: Failed with result 'exit-code'.
Apr 14 10:54:51 Komachan systemd[2127]: wluma.service: Scheduled restart job, restart counter is at 5.
Apr 14 10:54:51 Komachan systemd[2127]: wluma.service: Start request repeated too quickly.
Apr 14 10:54:51 Komachan systemd[2127]: wluma.service: Failed with result 'exit-code'.
Apr 14 10:54:51 Komachan systemd[2127]: Failed to start Adjusting screen brightness based on screen contents and amount of ambient light.

iio デバイスがない。実際、/sys/bus/iio は存在しなかった。カーネル的には対応しているので、ハード的にないのでしょうか。

一応WEBCamで疑似的にALS(Ambient Light Sensor)の代替をできるらしいです。

まとめ

できなかったぞよ!

Macのキーマップ変えてみた

いい感じに設定できて嬉しいのでkarabinerについてだけ記事を書いたなのです。Macのカスタマイズまとめはまた後日書くなのです。

Karabiner 最強なのです

JSONを直接書くのはしんどいのでkarabiner.tsというライブラリを用いてTypeScriptで設定を書き、ビルドしてコンフィグを生成します。

あらかじめGUIで権限周りの許可や、キーボードタイプを内部的にANSIにする必要があります。まだ途中ですが、かなりいい感じです。

ちなみにyabaiというタイル型ウィンドウマネージャーを使用しています(ヤバい)。

  • かな → IME切替
  • 英数 + hjkl → ウィンドウのフォーカス移動
  • 英数 + shift + hjkl → ウィンドウの移動
  • 英数 + q → ウィンドウを閉じる
  • 英数 + 任意のキー → 任意のアプリケーション起動
  • 英数単押し → ランチャー起動(Raycast)
  • Capslock → Command

また、Chrome限定で

  • Ctrl + w → Command + w
  • Ctrl + t → Command + t
  • Ctrl + l → Command + l

を当てています。TypeScriptはこんな感じです。

const yabai = "/run/current-system/sw/bin/yabai ";
writeToProfile("Default profile", [
rule("IME-toggle").manipulators([
map("japanese_kana")
.to("japanese_eisuu")
.condition(ifInputSource({ language: "ja" })),
]),
rule("Modifiers").manipulators([
map("caps_lock").to("left_command"),
map("left_control").to("left_control").toIfAlone("escape"),
]),
// Disable system shortcuts
rule("Disable-system").manipulators([map("q", "command").toNone()]),
layer("japanese_eisuu", "super")
.configKey((v) => v.toIfAlone("spacebar", "command"), true)
.manipulators([
// focus window
map("h").to$(yabai + "-m window --focus west"),
map("j").to$(yabai + "-m window --focus south"),
map("k").to$(yabai + "-m window --focus north"),
map("l").to$(yabai + "-m window --focus east"),
// move wndow
map("h", "shift").to$(yabai + "-m window --warp west"),
map("j", "shift").to$(yabai + "-m window --warp south"),
map("k", "shift").to$(yabai + "-m window --warp north"),
map("l", "shift").to$(yabai + "-m window --warp east"),
// other window operations
map("tab").to$(yabai + "-m window --focus recent"),
map("q").to$(yabai + "-m window --close"),
// applications
map("f", "shift").to$(
yabai + "-m window --toggle float --grid 4:4:1:1:2:2",
),
map("w").to$(
yabai +
"-m window --toggle float;" +
yabai +
"-m window --grid 1:1:0:0:1:1",
),
map("return_or_enter").to$("/usr/bin/open -a kitty ~"),
map("o").to$(
"$HOME/.nix-profile/bin/google-chrome-stable --profile-directory=Default",
),
]),
...

おわりに

既存の修飾キーを一切潰すことなく「英数」で修飾キーを増やせたような形になるなので、Hyprland時代よりもキーマップの自由度が高くなったなのです!

あとはSIP(Security Integration Protection)を一部無効化しないとワークスペース(デスクトップ)をまたぐ操作ができないのが悩みどころなのです……。

Hyprland に Plasma Browser Integration を入れた

Plasma Brwoser Integration とは

KDE Plasma というデスクトップ環境のコンポーネントの一つでChrome拡張とセットで使用します。 KRunner(ランチャー)からChromeのタブを直接開けたり、ブラウザ内の右クリックで簡単にKDE Connectで他デバイスに転送できます。

今回は、このKDE Connectとの連携が欲しかったため、本来KDE Plasmaとは関係のないHyprlandで動かそうと思いました

Home Manager で設定を書く

Chrome拡張のNativeMessagingHostsという機能を使って通信しているので、パッケージからいい感じにシンボリックリンクを張るだけです。

私のbrowser.nixは以下のようになりました。

{ pkgs, ... }: {
programs = {
firefox.enable = true;
google-chrome = {
enable = true;
commandLineArgs = [
"--enable-features=UseOzonePlatform"
"--ozone-platform=wayland"
"--enable-wayland-ime"
];
};
};
home.file.".config/google-chrome/NativeMessagingHosts/org.kde.plasma.browser_integration.json" = {
source = "${pkgs.plasma-browser-integration}/etc/chromium/native-messaging-hosts/org.kde.plasma.browser_integration.json";
};
home.file.".local/share/applications/org.kde.plasma.browser_integration.desktop" = {
source = "${pkgs.plasma-browser-integration}/share/applications/org.kde.plasma.browser_integration.desktop";
};
}

まとめ

これで Hyprland で動かしている KDE Plasma のコンポーネントは kde connect, kde wallet, xembedsniproxy, plasma-browser-integration になったなのです。 KDE Plasma 自体は苦手だけど便利なものは多いなのです。