mirror of
https://github.com/smg1024/nix-darwin.git
synced 2026-05-22 20:32:59 +09:00
feat: export sops age key file
This commit is contained in:
parent
725e9f6d87
commit
d54f1b591a
3 changed files with 22 additions and 9 deletions
|
|
@ -20,7 +20,7 @@ Declarative macOS setup with `nix-darwin`, `home-manager`, `nix-homebrew`, and
|
||||||
- SOPS age key at:
|
- SOPS age key at:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
~/.config/sops/age/keys.txt
|
$HOME/.config/sops/age/keys.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
## Repository Layout
|
## Repository Layout
|
||||||
|
|
@ -78,9 +78,9 @@ just gc
|
||||||
- `modules/flake/darwin-configurations.nix` assembles each host’s
|
- `modules/flake/darwin-configurations.nix` assembles each host’s
|
||||||
`darwinConfigurations.<host>` output and embeds Home Manager for user `poby`.
|
`darwinConfigurations.<host>` output and embeds Home Manager for user `poby`.
|
||||||
- `modules/aspects/` is the feature vocabulary for hosts. The current feature
|
- `modules/aspects/` is the feature vocabulary for hosts. The current feature
|
||||||
set is `base`, `nix-core`, `system-packages`, `homebrew`,
|
set is `base`, `nix-core`, `system-packages`, `homebrew`, `macos-defaults`,
|
||||||
`macos-defaults`, `activation`, `fonts`, `sudo-auth`, `shell`, `cli-tools`,
|
`activation`, `fonts`, `sudo-auth`, `shell`, `cli-tools`, `git`, `ssh`,
|
||||||
`git`, `ssh`, `secrets`, `terminal`, `editor`, `desktop`, and `fenrir`.
|
`secrets`, `terminal`, `editor`, `desktop`, and `fenrir`.
|
||||||
- The `cli-tools` aspect owns the CLI user tool set, including `zoxide`.
|
- The `cli-tools` aspect owns the CLI user tool set, including `zoxide`.
|
||||||
- `modules/aspects/_*/` contains implementation files that are intentionally not
|
- `modules/aspects/_*/` contains implementation files that are intentionally not
|
||||||
auto-loaded. `import-tree` skips paths containing `/_`, which is the repo’s
|
auto-loaded. `import-tree` skips paths containing `/_`, which is the repo’s
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
{config, ...}: {
|
{config, ...}: let
|
||||||
|
ageKeyFile = "${config.home.homeDirectory}/.config/sops/age/keys.txt";
|
||||||
|
in {
|
||||||
|
home.sessionVariables = {
|
||||||
|
SOPS_AGE_KEY_FILE = ageKeyFile;
|
||||||
|
};
|
||||||
|
|
||||||
sops = {
|
sops = {
|
||||||
age.keyFile = "${config.home.homeDirectory}/.config/sops/age/keys.txt";
|
age.keyFile = ageKeyFile;
|
||||||
|
|
||||||
defaultSopsFile = config.repo.user.secretFile;
|
defaultSopsFile = config.repo.user.secretFile;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ aspect. Do not commit plaintext secrets.
|
||||||
- Secret file: `secrets/poby.yaml`
|
- Secret file: `secrets/poby.yaml`
|
||||||
- SOPS rules: `.sops.yaml`
|
- SOPS rules: `.sops.yaml`
|
||||||
- Age key file: `~/.config/sops/age/keys.txt`
|
- Age key file: `~/.config/sops/age/keys.txt`
|
||||||
|
- Environment variable: `SOPS_AGE_KEY_FILE`, exported by the `secrets` aspect
|
||||||
- Secret declarations: `modules/aspects/_secrets/sops.nix`
|
- Secret declarations: `modules/aspects/_secrets/sops.nix`
|
||||||
- SSH host wiring: `modules/aspects/_ssh/ssh.nix`
|
- SSH host wiring: `modules/aspects/_ssh/ssh.nix`
|
||||||
|
|
||||||
|
|
@ -22,7 +23,7 @@ nix-shell -p sops age
|
||||||
Open the encrypted secret file with the age key:
|
Open the encrypted secret file with the age key:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
SOPS_AGE_KEY_FILE="$HOME/.config/sops/age/keys.txt" sops secrets/poby.yaml
|
sops secrets/poby.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
Add a top-level key name and paste the private key as a YAML block scalar:
|
Add a top-level key name and paste the private key as a YAML block scalar:
|
||||||
|
|
@ -38,6 +39,13 @@ Save and quit the editor. SOPS will re-encrypt the file automatically.
|
||||||
|
|
||||||
Do not edit the `sops:` metadata block manually.
|
Do not edit the `sops:` metadata block manually.
|
||||||
|
|
||||||
|
If this machine has not applied the Home Manager config yet, set the age key
|
||||||
|
file explicitly for the command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
SOPS_AGE_KEY_FILE="$HOME/.config/sops/age/keys.txt" sops secrets/poby.yaml
|
||||||
|
```
|
||||||
|
|
||||||
## Generate A New SSH Key First
|
## Generate A New SSH Key First
|
||||||
|
|
||||||
If the key does not exist yet, generate it before opening SOPS:
|
If the key does not exist yet, generate it before opening SOPS:
|
||||||
|
|
@ -89,7 +97,6 @@ Confirm the encrypted file contains the expected top-level secret names without
|
||||||
printing secret values:
|
printing secret values:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
SOPS_AGE_KEY_FILE="$HOME/.config/sops/age/keys.txt" \
|
|
||||||
sops -d secrets/poby.yaml \
|
sops -d secrets/poby.yaml \
|
||||||
| awk -F: '/^[A-Za-z0-9_]+:/ { print $1 }'
|
| awk -F: '/^[A-Za-z0-9_]+:/ { print $1 }'
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue