2025-05-31

何もしていないのにパソコンが壊れた

Nix
Nix

何もしていないのにパソコンが壊れた。

エンジニアにあるまじき発言ではあるが何もしていないのにパソコン (環境) が壊れてしまった。

Nix

PC の環境構築に Nix と呼ばれるパッケージ管理システムを使っている。 Nix を使っていると何が嬉しいのか、はインターネット上に熱い思いを語っている人たちに任せるとして、ここ数週間この Nix によって管理していた環境が壊れてしまった。壊れたというのは語弊があり、正確にはパッケージの更新ができない状態に陥っている。

Nix とは言ったが、macOS を使っているので正確には

の組合せになる。

この環境で sudo darwin-rebuild switch --flake を実行すると数週間前から次のようなエラーが発生するようになった。

1
$ sudo darwin-rebuild switch --flake .#private-aarch64-256GB
2
building the system configuration...
3
error:
4
while calling the 'derivationStrict' builtin
5
at <nix/derivation-internal.nix>:37:12:
6
36|
7
37| strict = derivationStrict drvAttrs;
8
| ^
9
38|
10
11
while evaluating derivation 'darwin-system-25.11.44a7d0e'
12
whose name attribute is located at /nix/store/s7ga48spdagfm0j1rd740q52ih159g51-source/pkgs/stdenv/generic/make-derivation.nix:480:13
13
14
while evaluating attribute 'activationScript' of derivation 'darwin-system-25.11.44a7d0e'
15
at /nix/store/a0qmksyiqyh60nda6fw7y1bzdv8w8vz2-source/modules/system/default.nix:89:7:
16
88|
17
89| activationScript = cfg.activationScripts.script.text;
18
| ^
19
90|
20
21
while evaluating the option `system.activationScripts.script.text':
22
23
… while evaluating definitions from `/nix/store/a0qmksyiqyh60nda6fw7y1bzdv8w8vz2-source/modules/system/activation-scripts.nix':
24
25
while evaluating the option `system.activationScripts.applications.text':
26
27
… while evaluating definitions from `/nix/store/a0qmksyiqyh60nda6fw7y1bzdv8w8vz2-source/modules/system/applications.nix':
28
29
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
30
31
error: Package 'glibc-nolibgcc-2.40-66' in /nix/store/s7ga48spdagfm0j1rd740q52ih159g51-source/pkgs/development/libraries/glibc/default.nix:217 is not available on the requested hostPlatform:
32
hostPlatform.config = "arm64-apple-darwin"
33
package.meta.platforms = [
34
"aarch64-linux"
35
"armv5tel-linux"
36
"armv6l-linux"
37
"armv7a-linux"
38
"armv7l-linux"
39
"i686-linux"
40
"loongarch64-linux"
41
"m68k-linux"
42
"microblaze-linux"
43
"microblazeel-linux"
44
"mips-linux"
45
"mips64-linux"
46
"mips64el-linux"
47
"mipsel-linux"
48
"powerpc64-linux"
49
"powerpc64le-linux"
50
"riscv32-linux"
51
"riscv64-linux"
52
"s390-linux"
53
"s390x-linux"
54
"x86_64-linux"
55
]
56
package.meta.badPlatforms = [ ]
57
, refusing to evaluate.
58
59
a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
60
for a single invocation of the nix tools.
61
62
$ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1
63
64
Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
65
then pass `--impure` in order to allow use of environment variables.
66
67
b) For `nixos-rebuild` you can set
68
{ nixpkgs.config.allowUnsupportedSystem = true; }
69
in configuration.nix to override this.
70
71
c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
72
{ allowUnsupportedSystem = true; }
73
to ~/.config/nixpkgs/config.nix.

この影響でアプリケーションのインストールもアップロードもできなくなってしまった。

原因はエラーメッセージにもあるように現在の環境が arm64-apple-darwin として認識されていることだろう。

これのせいで業務にも支障が出そうだったので調べていたら GitHub で関連する Issue が見つかったのでメモしておく。関連する Issue の様子を見ると解消には時間がかかりそうだ。

システム名称の変更

どうやら事の発端は NixOS/nixpkgs に lib/systems: use Darwin architecture names for config and uname by emilazy · Pull Request #393213 · NixOS/nixpkgs という PR が入ったことのようだ。

これまで ARM 64 ビット macOS (Apple Silicon) は aarch64-apple-darwin という名称で扱われていたがこの PR から arm64-apple-darwin という名称に変更されている。この変更自体も LLVM 20 での変更に対応するための修正であるため、一番悪いのは LLVM。

AArch64 と arm64 という名称の使い分けについて意識していなかったが、LLVM の文脈では LLVM のバックエンドの aarch64 と arm64 の違い - 組み込みの人。 に書かれているように AArch64 は ARM によって作られたもので、ARM64 は Apple が作ったものらしい。この記事では AArch64 の方に統一する動きがあったようだけど、月日が流れてまた別れることになったということなのかな…。

確かに手元で uname -m を実行すると arm64 と表示される。

1
$ uname -m
2
arm64

このあたりの不一致を解消したいのだろうが、この影響でビルドに失敗するパッケージが出ているようだ。

このあたりの PR、Issue の内容を見ると stdenv.hostPlatform.config を使わずにハードコーディングしていたようなパッケージや stdenv.hostPlatform.darwinArch を使っているパッケージがあおりを受けているようだ。

解決方法

調査中。現時点では nixpkgs の対応を待つしかない気がする。 全てのパッケージが使えない状態ということはないはずなので原因となっているパッケージを特定するしかないかもしれない。

原因判明。何と copilot-language-server をインストールしていたのが原因。以下の PR と原因としては同じ。

Emacs のパッケージも Nix で管理するようにしていたので copilot.el と一緒に入ってきていた copilot-language-server が原因だったという落ち。一時的に copilot.el をインストールしないようにしたら解決した。

おわりに

早く解決してくれー。