現象
Mac mini 上の Nix を一度消して再インストールしようとした。
sh <(curl -L https://nixos.org/nix/install)
ここで試しに nix-shell を使ってみたところ、下記のエラーが。
$ nix-shell -p git
error: Nix daemon disconnected unexpectedly (maybe it crashed?)
環境
- Mac mini (M1, 2020)
- macOS Sequoia
- Nix 2.28.0
解決
issue#12011 や NixOS Discourse で解決法が示されている。
まず、下記の場所にシンボリックリンクがあるはずである。
ls -la /etc/ssl/certs/ca-certificates.crt
出力:
lrwxr-xr-x 1 root wheel 41 Jul 15 2022 /etc/ssl/certs/ca-certificates.crt -> /etc/static/ssl/certs/ca-certificates.crt
しかしこのリンク先ファイルが存在しない。
$ ls /etc/static/ssl/certs/ca-certificates.crt
ls: cannot access '/etc/static/ssl/certs/ca-certificates.crt': No such file or directory
これが理由でデーモンが起動できていない様子なので、正しいファイルへリンクを貼り直してやればよいとのこと。
sudo rm /etc/ssl/certs/ca-certificates.crt
sudo ln -s /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt
動作確認
$ nix-shell -p hello
this path will be fetched (0.02 MiB download, 0.11 MiB unpacked):
/nix/store/zh4ha2m108qnkzib36mxchngqj4j13hn-hello-2.12.1
copying path '/nix/store/zh4ha2m108qnkzib36mxchngqj4j13hn-hello-2.12.1' from 'https://cache.nixos.org'...
[nix-shell:~/dotfiles]$ hello
Hello, world!
おわり。