Skip to content

Commit 2a40dbb

Browse files
committed
Harden AWS image pipeline and cleanup host config
1 parent 50f4016 commit 2a40dbb

File tree

13 files changed

+75
-139
lines changed

13 files changed

+75
-139
lines changed

.github/workflows/image-build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3636
AWS_REGION: ${{ secrets.AWS_REGION }}
3737
S3_BUCKET: ${{ secrets.S3_BUCKET }}
38-
S3_PREFIX: ${{ secrets.S3_PREFIX }}
3938
run: |
4039
key="$(scripts/upload-image.sh)"
4140
echo "S3_KEY=${key}" >> "${GITHUB_ENV}"

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Deploy flow (automation-first):
4444
- Bootstrap S3 bucket + scoped IAM user + VM Import role with `infra/opentofu/aws` (use homelab-admin creds).
4545
- Import the image into AWS as an AMI (`aws ec2 import-image`).
4646
- Grab the host SSH key and add it to `../nix/nix-secrets/secrets.nix`; rekey secrets with agenix.
47-
- Ensure required secrets exist: `clawdinator-github-app.pem`, `clawdinator-discord-token`, `anthropic-api-key`.
47+
- Ensure required secrets exist: `clawdinator-github-app.pem`, `clawdinator-discord-token`, `clawdinator-anthropic-api-key`.
4848
- Update `nix/hosts/<host>.nix` (Discord allowlist, GitHub App installationId, identity name).
4949
- Ensure `/var/lib/clawd/repo` contains this repo (self-update requires it).
5050
- Verify systemd services: `clawdinator`, `clawdinator-github-app-token`, `clawdinator-self-update`.
@@ -53,4 +53,4 @@ Deploy flow (automation-first):
5353
Key principle: mental notes don’t survive restarts — write it to a file.
5454

5555
Cattle vs pets: hosts are disposable. Prefer re-provisioning from OpenTofu + NixOS configs over in-place manual fixes.
56-
One way only: AWS AMI pipeline via S3 + VM Import. This is a greenfield repo. Do not reference "existing", "legacy", or alternate paths anywhere in code or docs.
56+
One way only: AWS AMI pipeline via S3 + VM Import. This is a greenfield repo. Do not reference alternate paths anywhere in code or docs.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Deploy (automation‑first):
4444
- Ensure `/var/lib/clawd/repo` contains this repo (needed for self‑update).
4545
- Configure Discord guild/channel allowlist and GitHub App installation ID.
4646

47-
Image-based deploy (Option A, recommended):
47+
Image-based deploy (only path):
4848
1) Build a bootstrap image with nixos-generators:
4949
- `nix run github:nix-community/nixos-generators -- -f amazon -c nix/hosts/clawdinator-1-image.nix -o dist`
5050
2) Upload the raw image to S3 (private object).

docs/SECRETS.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Infrastructure (OpenTofu):
88

99
Image pipeline (CI):
1010
- `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_REGION` / `S3_BUCKET` (required).
11-
- `S3_PREFIX` (optional).
1211

1312
Local storage:
1413
- Keep AWS keys encrypted in `../nix/nix-secrets` for local runs if needed.
@@ -33,8 +32,8 @@ Agenix (local secrets repo):
3332
- Store encrypted files in `../nix/nix-secrets` (relative to this repo).
3433
- Sync encrypted secrets to the host at `/var/lib/clawd/nix-secrets`.
3534
- Decrypt on host with agenix; point NixOS options at `/run/agenix/*`.
36-
- Required files (minimum): `clawdinator-github-app.pem.age`, `clawdinator-discord-token.age`, `clawdis-anthropic-api-key.age`.
37-
- CI image pipeline (stored locally, not on hosts): `clawdinator-ami-importer-access-key-id.age`, `clawdinator-ami-importer-secret-access-key.age`, `clawdinator-image-bucket-name.age`, `clawdinator-image-bucket-region.age`.
35+
- Required files (minimum): `clawdinator-github-app.pem.age`, `clawdinator-discord-token.age`, `clawdinator-anthropic-api-key.age`.
36+
- CI image pipeline (stored locally, not on hosts): `clawdinator-image-uploader-access-key-id.age`, `clawdinator-image-uploader-secret-access-key.age`, `clawdinator-image-bucket-name.age`, `clawdinator-image-bucket-region.age`.
3837

3938
Example NixOS wiring (agenix):
4039
```
@@ -44,15 +43,15 @@ Example NixOS wiring (agenix):
4443
4544
age.secrets."clawdinator-github-app.pem".file =
4645
"/var/lib/clawd/nix-secrets/clawdinator-github-app.pem.age";
47-
age.secrets."clawdis-anthropic-api-key".file =
48-
"/var/lib/clawd/nix-secrets/clawdis-anthropic-api-key.age";
46+
age.secrets."clawdinator-anthropic-api-key".file =
47+
"/var/lib/clawd/nix-secrets/clawdinator-anthropic-api-key.age";
4948
age.secrets."clawdinator-discord-token".file =
5049
"/var/lib/clawd/nix-secrets/clawdinator-discord-token.age";
5150
5251
services.clawdinator.githubApp.privateKeyFile =
5352
"/run/agenix/clawdinator-github-app.pem";
5453
services.clawdinator.anthropicApiKeyFile =
55-
"/run/agenix/clawdis-anthropic-api-key";
54+
"/run/agenix/clawdinator-anthropic-api-key";
5655
services.clawdinator.discordTokenFile =
5756
"/run/agenix/clawdinator-discord-token";
5857
}

docs/SHARED_MEMORY.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ POC recommendation:
77
- Memory lives at /var/lib/clawd/memory.
88

99
File patterns:
10-
- Daily notes (optionally per instance): YYYY-MM-DD_INSTANCE.md
10+
- Daily notes can be per instance: YYYY-MM-DD_INSTANCE.md (merge later).
1111
- Canonical knowledge (single shared files):
1212
- project.md (goals + non-negotiables)
1313
- architecture.md
@@ -23,11 +23,11 @@ Example layout:
2323
│ ├── architecture.md
2424
│ ├── discord.md
2525
│ ├── whatsapp.md
26-
│ └── 2026-01-06_CLAWDINATOR-1.md
26+
│ └── 2026-01-06.md
2727
```
2828

2929
AGENTS.md should reference key memory files explicitly (e.g., “For Discord context, also read memory/discord.md”).
3030

31-
Later scale options:
32-
- Shared filesystem or object storage sync with file locking.
31+
Multi-host requirement:
32+
- Use a shared filesystem or object storage sync with file locking.
3333
- Keep canonical files authoritative; merge per-instance notes periodically.

flake.nix

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
nix-clawdbot.url = "github:clawdbot/nix-clawdbot"; # latest upstream
77
agenix.url = "github:ryantm/agenix";
8-
disko.url = "github:nix-community/disko";
98
secrets = {
109
url = "path:../nix/nix-secrets";
1110
flake = false;
1211
};
1312
};
1413

15-
outputs = { self, nixpkgs, nix-clawdbot, agenix, disko, secrets }:
14+
outputs = { self, nixpkgs, nix-clawdbot, agenix, secrets }:
1615
let
1716
lib = nixpkgs.lib;
1817
systems = [ "x86_64-linux" "aarch64-linux" ];
@@ -88,17 +87,8 @@
8887
modules = [
8988
({ ... }: { nixpkgs.overlays = [ self.overlays.default ]; })
9089
agenix.nixosModules.default
91-
disko.nixosModules.disko
9290
./nix/hosts/clawdinator-1.nix
9391
];
9492
};
95-
96-
nixosConfigurations.clawdinator-1-bootstrap = nixpkgs.lib.nixosSystem {
97-
system = "x86_64-linux";
98-
modules = [
99-
disko.nixosModules.disko
100-
./nix/hosts/clawdinator-1-bootstrap.nix
101-
];
102-
};
10393
};
10494
}

nix/examples/clawdinator-host.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{
33
age.secrets."clawdinator-github-app.pem".file =
44
"/var/lib/clawd/nix-secrets/clawdinator-github-app.pem.age";
5-
age.secrets."clawdis-anthropic-api-key".file =
6-
"/var/lib/clawd/nix-secrets/clawdis-anthropic-api-key.age";
5+
age.secrets."clawdinator-anthropic-api-key".file =
6+
"/var/lib/clawd/nix-secrets/clawdinator-anthropic-api-key.age";
77
age.secrets."clawdinator-discord-token".file =
88
"/var/lib/clawd/nix-secrets/clawdinator-discord-token.age";
99

@@ -40,7 +40,7 @@
4040
};
4141
};
4242

43-
anthropicApiKeyFile = "/run/agenix/clawdis-anthropic-api-key";
43+
anthropicApiKeyFile = "/run/agenix/clawdinator-anthropic-api-key";
4444
discordTokenFile = "/run/agenix/clawdinator-discord-token";
4545

4646
githubApp = {

nix/hosts/clawdinator-1-bootstrap.nix

Lines changed: 0 additions & 52 deletions
This file was deleted.

nix/hosts/clawdinator-1-image.nix

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
{ modulesPath, ... }:
22
{
33
imports = [
4-
(modulesPath + "/profiles/qemu-guest.nix")
4+
(modulesPath + "/virtualisation/amazon-image.nix")
55
];
66

77
networking.hostName = "clawdinator-1";
88
time.timeZone = "UTC";
99
system.stateVersion = "26.05";
10-
11-
boot.loader.systemd-boot.enable = true;
12-
boot.loader.grub.enable = false;
13-
boot.loader.efi.canTouchEfiVariables = false;
14-
boot.loader.efi.efiSysMountPoint = "/boot";
15-
16-
networking.useDHCP = false;
17-
systemd.network.enable = true;
18-
systemd.network.networks."10-ethernet" = {
19-
matchConfig.Name = [ "en*" "eth*" ];
20-
networkConfig.DHCP = "yes";
21-
};
22-
services.openssh.enable = true;
23-
networking.firewall.enable = false;
24-
25-
users.users.root.openssh.authorizedKeys.keys = [
26-
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOLItFT3SVm5r7gELrfRRJxh6V2sf/BIx7HKXt6oVWpB"
27-
];
2810
}

nix/hosts/clawdinator-1.nix

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,27 @@
1-
{ config, lib, pkgs, secrets, ... }:
1+
{ modulesPath, pkgs, ... }:
22
{
3-
imports = [ ../modules/clawdinator.nix ];
3+
imports = [
4+
(modulesPath + "/virtualisation/amazon-image.nix")
5+
../modules/clawdinator.nix
6+
];
47

58
networking.hostName = "clawdinator-1";
6-
networking.useDHCP = false;
7-
networking.useNetworkd = true;
8-
systemd.network.enable = true;
9-
systemd.network.networks."10-wan" = {
10-
matchConfig.Type = "ether";
11-
networkConfig.DHCP = "yes";
12-
};
139
time.timeZone = "UTC";
1410
system.stateVersion = "26.05";
1511

16-
boot.loader.systemd-boot.enable = true;
17-
boot.loader.grub.enable = false;
18-
boot.loader.efi.canTouchEfiVariables = false;
19-
boot.loader.efi.efiSysMountPoint = "/boot";
20-
21-
fileSystems."/" = {
22-
device = "/dev/disk/by-partlabel/disk-main-root";
23-
fsType = "ext4";
24-
};
25-
26-
fileSystems."/boot" = {
27-
device = "/dev/disk/by-partlabel/disk-main-boot";
28-
fsType = "vfat";
29-
};
30-
3112
nix.package = pkgs.nixVersions.stable;
3213
nix.settings.experimental-features = [ "nix-command" "flakes" ];
3314

34-
services.openssh.enable = true;
3515
networking.firewall.allowedTCPPorts = [ 22 18789 ];
36-
users.users.root.openssh.authorizedKeys.keys = [
37-
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOLItFT3SVm5r7gELrfRRJxh6V2sf/BIx7HKXt6oVWpB"
38-
];
3916

4017
age.identityPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
4118
age.secrets."clawdinator-github-app.pem" = {
4219
file = "/var/lib/clawd/nix-secrets/clawdinator-github-app.pem.age";
4320
owner = "clawdinator";
4421
group = "clawdinator";
4522
};
46-
age.secrets."clawdis-anthropic-api-key" = {
47-
file = "/var/lib/clawd/nix-secrets/clawdis-anthropic-api-key.age";
23+
age.secrets."clawdinator-anthropic-api-key" = {
24+
file = "/var/lib/clawd/nix-secrets/clawdinator-anthropic-api-key.age";
4825
owner = "clawdinator";
4926
group = "clawdinator";
5027
};
@@ -88,7 +65,7 @@
8865
};
8966
};
9067

91-
anthropicApiKeyFile = "/run/agenix/clawdis-anthropic-api-key";
68+
anthropicApiKeyFile = "/run/agenix/clawdinator-anthropic-api-key";
9269
discordTokenFile = "/run/agenix/clawdinator-discord-token";
9370

9471
githubApp = {

0 commit comments

Comments
 (0)