feat(sops): 秘密をホスト単位のファイルに分割する - #393
Merged
Merged
Conversation
これまで secrets/secrets.yaml 1本を mac / laptop / WSL の3ホストが同じ secrets.nix 経由で読んでいたため、Linux 側のリビルドでも Xcode の Apple ID と keystats の署名鍵がディスクに書き出されていた。どちらもそこでは使えない資格情報。 common / darwin / homelab の3ファイルに分け、.sops.yaml でファイルごとに受信者を 変えた。darwin.yaml は mac のホスト鍵まで、homelab.yaml は人間の鍵だけが開ける。 分割は「元ファイルの全リーフパスが出力のどれかにちょうど1回現れる」ことを検証して から実施した (unified_calendar/admin_token の振り分け漏れをこれで検出)。 ホスト鍵は .sops.yaml に受信者として入れてあるが、この PR ではまだ使わない。 home-manager の sops はユーザ権限で動き、/etc/ssh/ssh_host_ed25519_key は 0600 root:wheel なので、ホスト鍵での復号はシステム側 sops でないと届かない。 radicale (username/password) は作業ツリーに未コミットで残っていたものを取り込んだ。 PR #375 の平たい radicale_password はこれに置き換わる。
gapul
force-pushed
the
feat/sops-per-host
branch
from
August 20, 2026 12:28
528ca0f to
84fac8a
Compare
This was referenced Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
なぜ
secrets/secrets.yaml1本を mac / laptop / WSL の3ホストが同じhome/secrets.nix経由で読んでいた。結果として Linux 側のリビルドでも、Xcode の Apple ID と keystats の macOS 署名鍵がディスクに書き出されていた。そこでは使い道のない資格情報が、ただ露出面として増えていた状態。変更
common/darwin/homelabの3ファイルに分け、.sops.yamlで ファイルごとに受信者を変えた。secrets/common.yamlsecrets/darwin.yamlsecrets/homelab.yamlhome/secrets.nixは common 専用になり、mac 固有分は新しいhome/secrets-darwin.nixに移してmacWorkstationロールだけが読む。home/mopidy.nixの2つはsopsFileで darwin.yaml を指す。分割はモジュールの import だけでなく 受信者そのもので担保されている。laptop で
secrets/darwin.yamlを開こうとしても鍵が無い。分割の検証
「元ファイルの全リーフパスが、出力3ファイルのどれかにちょうど1回だけ現れる」ことを機械的に確認してから書き出した。欠落・重複・存在しないパスの捏造をそれぞれ別に検出する。
実際にこのチェックが2件拾っている。
unified_calendar/admin_tokenの振り分け漏れと、後述の radicale。ホスト鍵についての注意
.sops.yamlには mac と macmini のホスト鍵 (SSH ホスト鍵からssh-to-ageで導出) を受信者として入れたが、この PR ではまだ使っていない。home-manager の sops はユーザ権限で動くのに対し
/etc/ssh/ssh_host_ed25519_keyは0600 root:wheelなので、ホスト鍵での復号はシステム側 (nix-darwin / NixOS) の sops でないと届かない。受信者を先に入れてあるのは、後から足すと秘密ファイルを再暗号化することになり、そのたびに平文を触る手数が増えるため。次の PR でシステム側に配線する。radicale について
作業ツリーに未コミットで残っていた
radicale: {username, password}を取り込んだ。同じ差分にあった rclone_conf の再暗号化も一緒に入っている。open な #375 が持っている平たい
radicale_passwordはこれに置き換わるので、#375 は rebase してsecrets.nixの参照をradicale/usernameとradicale/passwordに直す必要がある。#375 側のsecrets/secrets.yamlへの変更は、このファイルが無くなるため破棄でよい。マージ後にローカルでやること
~/.dotfilesの作業ツリーにsecrets/secrets.yamlの変更が残っている。中身はこの PR に取り込み済みなので、pull の前に捨てる。git -C ~/.dotfiles checkout -- secrets/secrets.yaml確認
darwinConfigurations.{gapul,macmini},homeConfigurations.gapul,nixosConfigurations.{homeserver,nixos-laptop-ci,wsl}すべて eval が通るnix fmt差分なし、just docs差分なし