devbox on macOS (#488) Task 4: the LaunchDaemon plist and the runbook's macOS section
infra/devbox/com.carlosframework.devbox.plist: launchd binds 100.64.0.10:443 (IPv4 stream, the runbook's placeholder) as the Sockets entry Listeners and starts carlos devbox serve --env-file /usr/local/etc/carlos-devbox/env as _carlos-devbox, RunAtLoad and KeepAlive, logging to /usr/local/var/log/carlos-devbox.log. Its only environment is CARLOS_DEVBOX_LAUNCHD_SOCKET=Listeners: no secrets. TestDevboxPlistIsWellFormed reads it with encoding/xml (plutil does not run on Linux), checks every key, and refuses any AWS_ name. infra/devbox/README.md: "Install on macOS, once, as root": the role user and group by dscl, the data, socket and log paths, the env file, the binary and plist, bootstrap, the kickstart note, and the pointer to the DNS step and checks. Copy: Paul approved DBX-C58..C92 unchanged; all are now approved and in devboxCopyBuilt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+390
−35
approved_devbox_copy_test.go+2 −0devbox_plist_test.go+196 −0docs/superpowers/plans/2026-10-30-devbox-mode-copy.md+35 −35infra/devbox/README.md+89 −0infra/devbox/com.carlosframework.devbox.plist+68 −0
CI failed — run details
Intent
Attributed to this commit: 20.4 g CO₂e (2,558,454 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on devbox-macos, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/approved_devbox_copy_test.go b/approved_devbox_copy_test.go| index e3aac5603..60ec5a594 100644 |
| --- a/approved_devbox_copy_test.go |
| +++ b/approved_devbox_copy_test.go |
| @@ -36,6 +36,8 @@ var devboxCopyIDs = func() []string { |
| // The task that writes a row's text adds its id here in the same commit. |
| var devboxCopyBuilt = []string{ |
| "DBX-C1", "DBX-C2", "DBX-C3", "DBX-C4", "DBX-C5", "DBX-C6", "DBX-C7", "DBX-C8", "DBX-C9", "DBX-C10", "DBX-C11", "DBX-C12", "DBX-C13", "DBX-C14", "DBX-C15", "DBX-C16", "DBX-C17", "DBX-C18", "DBX-C19", "DBX-C20", "DBX-C21", "DBX-C22", "DBX-C23", "DBX-C24", "DBX-C25", "DBX-C26", "DBX-C27", "DBX-C28", "DBX-C29", "DBX-C30", "DBX-C31", "DBX-C32", "DBX-C33", "DBX-C34", "DBX-C35", "DBX-C36", "DBX-C37", "DBX-C38", "DBX-C39", "DBX-C40", "DBX-C41", "DBX-C42", "DBX-C43", "DBX-C44", "DBX-C45", "DBX-C46", "DBX-C47", "DBX-C48", "DBX-C49", "DBX-C50", "DBX-C51", "DBX-C52", "DBX-C53", "DBX-C54", "DBX-C55", "DBX-C56", "DBX-C57", |
| + // macOS (#488) |
| + "DBX-C58", "DBX-C59", "DBX-C60", "DBX-C61", "DBX-C62", "DBX-C63", "DBX-C64", "DBX-C65", "DBX-C66", "DBX-C67", "DBX-C68", "DBX-C69", "DBX-C70", "DBX-C71", "DBX-C72", "DBX-C73", "DBX-C74", "DBX-C75", "DBX-C76", "DBX-C77", "DBX-C78", "DBX-C79", "DBX-C80", "DBX-C81", "DBX-C82", "DBX-C83", "DBX-C84", "DBX-C85", "DBX-C86", "DBX-C87", "DBX-C88", "DBX-C89", "DBX-C90", "DBX-C91", "DBX-C92", |
| } |
| func mustParseDevboxRecord(t *testing.T) []copyRow { |
diff --git a/devbox_plist_test.go b/devbox_plist_test.go| new file mode 100644 |
| index 000000000..77630eb4e |
| --- /dev/null |
| +++ b/devbox_plist_test.go |
| @@ -0,0 +1,196 @@ |
| +package main |
| + |
| +// The macOS LaunchDaemon (infra/devbox/com.carlosframework.devbox.plist, |
| +// macOS plan #488 Task 4). plutil does not run on Linux, so this reads the |
| +// plist as XML with encoding/xml, builds its values, and checks each key |
| +// the plan sets. launchd binds the socket as root; the service runs as its |
| +// own user and reads its secrets from the env file, so the plist, which |
| +// every account can read, carries none. |
| + |
| +import ( |
| + "bytes" |
| + "encoding/xml" |
| + "errors" |
| + "fmt" |
| + "io" |
| + "os" |
| + "reflect" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +const devboxPlistPath = "infra/devbox/com.carlosframework.devbox.plist" |
| + |
| +// plistValue reads the value element start opened: a dict, an array, a |
| +// string, an integer (kept as its text) or true/false. |
| +func plistValue(d *xml.Decoder, start xml.StartElement) (any, error) { |
| + switch start.Name.Local { |
| + case "true", "false": |
| + if err := d.Skip(); err != nil { |
| + return nil, err |
| + } |
| + return start.Name.Local == "true", nil |
| + case "string", "integer", "key": |
| + var s string |
| + if err := d.DecodeElement(&s, &start); err != nil { |
| + return nil, err |
| + } |
| + return s, nil |
| + case "array": |
| + var out []any |
| + for { |
| + tok, err := d.Token() |
| + if err != nil { |
| + return nil, err |
| + } |
| + switch t := tok.(type) { |
| + case xml.StartElement: |
| + v, err := plistValue(d, t) |
| + if err != nil { |
| + return nil, err |
| + } |
| + out = append(out, v) |
| + case xml.EndElement: |
| + return out, nil |
| + } |
| + } |
| + case "dict": |
| + out := map[string]any{} |
| + key := "" |
| + for { |
| + tok, err := d.Token() |
| + if err != nil { |
| + return nil, err |
| + } |
| + switch t := tok.(type) { |
| + case xml.StartElement: |
| + v, err := plistValue(d, t) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if t.Name.Local == "key" { |
| + if key != "" { |
| + return nil, fmt.Errorf("key %q has no value", key) |
| + } |
| + key = v.(string) |
| + if _, dup := out[key]; dup { |
| + return nil, fmt.Errorf("key %q twice", key) |
| + } |
| + continue |
| + } |
| + if key == "" { |
| + return nil, fmt.Errorf("a <%s> with no key", t.Name.Local) |
| + } |
| + out[key], key = v, "" |
| + case xml.EndElement: |
| + if key != "" { |
| + return nil, fmt.Errorf("key %q has no value", key) |
| + } |
| + return out, nil |
| + } |
| + } |
| + } |
| + return nil, fmt.Errorf("unexpected <%s>", start.Name.Local) |
| +} |
| + |
| +// parsePlist reads a whole plist document: <plist version="1.0"> holding |
| +// one value, and nothing after it. |
| +func parsePlist(raw []byte) (any, error) { |
| + d := xml.NewDecoder(bytes.NewReader(raw)) |
| + var top any |
| + inPlist := false |
| + for { |
| + tok, err := d.Token() |
| + if errors.Is(err, io.EOF) { |
| + if top == nil { |
| + return nil, errors.New("no <plist> value") |
| + } |
| + return top, nil |
| + } |
| + if err != nil { |
| + return nil, err |
| + } |
| + t, ok := tok.(xml.StartElement) |
| + if !ok { |
| + continue |
| + } |
| + if !inPlist { |
| + if t.Name.Local != "plist" { |
| + return nil, fmt.Errorf("the root is <%s>, not <plist>", t.Name.Local) |
| + } |
| + inPlist = true |
| + continue |
| + } |
| + if top != nil { |
| + return nil, fmt.Errorf("a second value, <%s>", t.Name.Local) |
| + } |
| + if top, err = plistValue(d, t); err != nil { |
| + return nil, err |
| + } |
| + } |
| +} |
| + |
| +func TestDevboxPlistIsWellFormed(t *testing.T) { |
| + raw, err := os.ReadFile(devboxPlistPath) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if strings.Contains(string(raw), "AWS_") { |
| + t.Fatal("the plist names an AWS_ variable; every account can read it, so secrets go in the env file") |
| + } |
| + top, err := parsePlist(raw) |
| + if err != nil { |
| + t.Fatalf("%s: %v", devboxPlistPath, err) |
| + } |
| + got, ok := top.(map[string]any) |
| + if !ok { |
| + t.Fatalf("the plist's value is %T, want a dict", top) |
| + } |
| + want := map[string]any{ |
| + "Label": "com.carlosframework.devbox", |
| + "ProgramArguments": []any{"/usr/local/bin/carlos", "devbox", "serve", "--env-file", "/usr/local/etc/carlos-devbox/env"}, |
| + "UserName": "_carlos-devbox", |
| + "GroupName": "_carlos-devbox", |
| + "Sockets": map[string]any{ |
| + "Listeners": map[string]any{ |
| + "SockNodeName": "100.64.0.10", |
| + "SockServiceName": "443", |
| + "SockType": "stream", |
| + "SockFamily": "IPv4", |
| + }, |
| + }, |
| + "RunAtLoad": true, |
| + "KeepAlive": true, |
| + "StandardOutPath": "/usr/local/var/log/carlos-devbox.log", |
| + "StandardErrorPath": "/usr/local/var/log/carlos-devbox.log", |
| + "EnvironmentVariables": map[string]any{"CARLOS_DEVBOX_LAUNCHD_SOCKET": "Listeners"}, |
| + } |
| + if !reflect.DeepEqual(got, want) { |
| + for k := range want { |
| + if !reflect.DeepEqual(got[k], want[k]) { |
| + t.Errorf("%s = %#v, want %#v", k, got[k], want[k]) |
| + } |
| + } |
| + for k := range got { |
| + if _, ok := want[k]; !ok { |
| + t.Errorf("unexpected key %s = %#v", k, got[k]) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// The reader itself refuses what plutil would. |
| +func TestDevboxPlistReaderRefuses(t *testing.T) { |
| + for _, bad := range []string{ |
| + `<plist version="1.0"><dict><key>A</key></dict></plist>`, |
| + `<plist version="1.0"><dict><key>A</key><string>x</string><key>A</key><string>y</string></dict></plist>`, |
| + `<plist version="1.0"><dict><string>x</string></dict></plist>`, |
| + `<plist version="1.0"><dict><key>A</key><string>x</string></plist>`, |
| + `<dict></dict>`, |
| + `<plist version="1.0"><dict></dict><dict></dict></plist>`, |
| + } { |
| + if _, err := parsePlist([]byte(bad)); err == nil { |
| + t.Errorf("parsePlist(%q) = nil error", bad) |
| + } |
| + } |
| +} |
diff --git a/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md b/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md| index a26827f90..0ea1292c9 100644 |
| --- a/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md |
| +++ b/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md |
| @@ -139,38 +139,38 @@ plist's `Sockets` entry, such as `Listeners`; `<count>` a number; |
| | id | file | text | status | |
| |---|---|---|---| |
| -| DBX-C58 | devbox_cli.go | usage: carlos devbox serve [--env-file <env file>] | pending | |
| -| DBX-C59 | devbox_cli.go | serve runs the devbox service. its systemd unit or launchd daemon starts it, and nobody else needs to | pending | |
| -| DBX-C60 | devbox_cli.go | a file of KEY=VALUE lines to read before serving. blank lines and lines starting with # are skipped, and values are taken as written, with no quotes. a setting in the file replaces one already in the environment. the file must belong to this account, and only this account may read or change it | pending | |
| -| DBX-C61 | devbox_cli.go | could not read the environment file <env file>. check that it exists and that this account can read it | pending | |
| -| DBX-C62 | devbox_cli.go | other accounts can read or change the environment file <env file>. make it private with: chmod 600 <env file> | pending | |
| -| DBX-C63 | devbox_cli.go | the environment file <env file> belongs to another account. it must belong to the account the service runs as | pending | |
| -| DBX-C64 | devbox_cli.go | line <line> of <env file> is not KEY=VALUE, where KEY is letters, digits and underscores and does not start with a digit. each line must be a setting, a comment starting with #, or blank | pending | |
| -| DBX-C65 | devbox_cli.go | <key> is set twice in <env file>, on lines <line> and <line>. keep one | pending | |
| -| DBX-C66 | devbox_cli.go | CARLOS_DEVBOX_LAUNCHD_SOCKET is set, but launchd did not start this process, so there is no socket to take. start the service with launchctl, or unset CARLOS_DEVBOX_LAUNCHD_SOCKET to run it by hand | pending | |
| -| DBX-C67 | devbox_cli.go | launchd has no socket called <socket name> for this service. the Sockets entry in the plist and CARLOS_DEVBOX_LAUNCHD_SOCKET must use the same name | pending | |
| -| DBX-C68 | devbox_cli.go | launchd handed over <count> sockets called <socket name>, and the service serves on exactly one. set SockFamily to IPv4 in the plist | pending | |
| -| DBX-C69 | devbox_cli.go | CARLOS_DEVBOX_LAUNCHD_SOCKET is set, but only macOS hands over sockets this way. unset it, and the service binds CARLOS_DEVBOX_LISTEN itself | pending | |
| -| DBX-C70 | devbox_cli.go | launchd's socket listens on every interface, <address>. set SockNodeName in the plist to the tailnet address in CARLOS_DEVBOX_LISTEN | pending | |
| -| DBX-C71 | devbox_cli.go | launchd's socket listens on <address>, but CARLOS_DEVBOX_LISTEN is <address>. make SockNodeName and SockServiceName in the plist match it | pending | |
| -| DBX-C72 | infra/devbox/README.md | ## Install on macOS, once, as root | pending | |
| -| DBX-C73 | infra/devbox/README.md | On a Mac, launchd binds port 443 on the tailnet address as root and hands the open socket to the service. | pending | |
| -| DBX-C74 | infra/devbox/README.md | The service runs as its own user, so no carlos process runs as root. | pending | |
| -| DBX-C75 | infra/devbox/README.md | Follow these steps instead of the Linux ones above. | pending | |
| -| DBX-C76 | infra/devbox/README.md | Create the service user and its group, both called _carlos-devbox. | pending | |
| -| DBX-C77 | infra/devbox/README.md | It is a hidden account with no login and no home folder. | pending | |
| -| DBX-C78 | infra/devbox/README.md | Give both the same ID, a number below 500 that no user or group has yet. | pending | |
| -| DBX-C79 | infra/devbox/README.md | The commands below use 451. | pending | |
| -| DBX-C80 | infra/devbox/README.md | Create the service's folders: one for its data, private to the service user, and one for the registrar socket, which every account can reach. | pending | |
| -| DBX-C81 | infra/devbox/README.md | Create the log file as well, owned by the service user. | pending | |
| -| DBX-C82 | infra/devbox/README.md | Write the environment file, private to the service user. | pending | |
| -| DBX-C83 | infra/devbox/README.md | It holds this Mac's tailnet address, the devbox domain, the data folder and the AWS key for the certificate challenge record. | pending | |
| -| DBX-C84 | infra/devbox/README.md | The service reads this file itself, because every account can read a plist. | pending | |
| -| DBX-C85 | infra/devbox/README.md | Install the carlos binary and the plist. | pending | |
| -| DBX-C86 | infra/devbox/README.md | In the plist, replace 100.64.0.10 with this Mac's tailnet address, the same one as in CARLOS_DEVBOX_LISTEN. | pending | |
| -| DBX-C87 | infra/devbox/README.md | The service refuses to start if launchd hands it a socket on any other address. | pending | |
| -| DBX-C88 | infra/devbox/README.md | Create the IAM user, key and policy as in the Linux steps above, then load the service. | pending | |
| -| DBX-C89 | infra/devbox/README.md | If the tailnet is not up when launchd loads the service, launchd cannot bind the address. | pending | |
| -| DBX-C90 | infra/devbox/README.md | Once the tailnet is up, start the service again. | pending | |
| -| DBX-C91 | infra/devbox/README.md | Then add the DNS record and run the checks below. | pending | |
| -| DBX-C92 | infra/devbox/README.md | On a Mac, use lsof instead of ss to see what is listening, and read the log file instead of journalctl. | pending | |
| +| DBX-C58 | devbox_cli.go | usage: carlos devbox serve [--env-file <env file>] | approved | |
| +| DBX-C59 | devbox_cli.go | serve runs the devbox service. its systemd unit or launchd daemon starts it, and nobody else needs to | approved | |
| +| DBX-C60 | devbox_cli.go | a file of KEY=VALUE lines to read before serving. blank lines and lines starting with # are skipped, and values are taken as written, with no quotes. a setting in the file replaces one already in the environment. the file must belong to this account, and only this account may read or change it | approved | |
| +| DBX-C61 | devbox_cli.go | could not read the environment file <env file>. check that it exists and that this account can read it | approved | |
| +| DBX-C62 | devbox_cli.go | other accounts can read or change the environment file <env file>. make it private with: chmod 600 <env file> | approved | |
| +| DBX-C63 | devbox_cli.go | the environment file <env file> belongs to another account. it must belong to the account the service runs as | approved | |
| +| DBX-C64 | devbox_cli.go | line <line> of <env file> is not KEY=VALUE, where KEY is letters, digits and underscores and does not start with a digit. each line must be a setting, a comment starting with #, or blank | approved | |
| +| DBX-C65 | devbox_cli.go | <key> is set twice in <env file>, on lines <line> and <line>. keep one | approved | |
| +| DBX-C66 | devbox_cli.go | CARLOS_DEVBOX_LAUNCHD_SOCKET is set, but launchd did not start this process, so there is no socket to take. start the service with launchctl, or unset CARLOS_DEVBOX_LAUNCHD_SOCKET to run it by hand | approved | |
| +| DBX-C67 | devbox_cli.go | launchd has no socket called <socket name> for this service. the Sockets entry in the plist and CARLOS_DEVBOX_LAUNCHD_SOCKET must use the same name | approved | |
| +| DBX-C68 | devbox_cli.go | launchd handed over <count> sockets called <socket name>, and the service serves on exactly one. set SockFamily to IPv4 in the plist | approved | |
| +| DBX-C69 | devbox_cli.go | CARLOS_DEVBOX_LAUNCHD_SOCKET is set, but only macOS hands over sockets this way. unset it, and the service binds CARLOS_DEVBOX_LISTEN itself | approved | |
| +| DBX-C70 | devbox_cli.go | launchd's socket listens on every interface, <address>. set SockNodeName in the plist to the tailnet address in CARLOS_DEVBOX_LISTEN | approved | |
| +| DBX-C71 | devbox_cli.go | launchd's socket listens on <address>, but CARLOS_DEVBOX_LISTEN is <address>. make SockNodeName and SockServiceName in the plist match it | approved | |
| +| DBX-C72 | infra/devbox/README.md | ## Install on macOS, once, as root | approved | |
| +| DBX-C73 | infra/devbox/README.md | On a Mac, launchd binds port 443 on the tailnet address as root and hands the open socket to the service. | approved | |
| +| DBX-C74 | infra/devbox/README.md | The service runs as its own user, so no carlos process runs as root. | approved | |
| +| DBX-C75 | infra/devbox/README.md | Follow these steps instead of the Linux ones above. | approved | |
| +| DBX-C76 | infra/devbox/README.md | Create the service user and its group, both called _carlos-devbox. | approved | |
| +| DBX-C77 | infra/devbox/README.md | It is a hidden account with no login and no home folder. | approved | |
| +| DBX-C78 | infra/devbox/README.md | Give both the same ID, a number below 500 that no user or group has yet. | approved | |
| +| DBX-C79 | infra/devbox/README.md | The commands below use 451. | approved | |
| +| DBX-C80 | infra/devbox/README.md | Create the service's folders: one for its data, private to the service user, and one for the registrar socket, which every account can reach. | approved | |
| +| DBX-C81 | infra/devbox/README.md | Create the log file as well, owned by the service user. | approved | |
| +| DBX-C82 | infra/devbox/README.md | Write the environment file, private to the service user. | approved | |
| +| DBX-C83 | infra/devbox/README.md | It holds this Mac's tailnet address, the devbox domain, the data folder and the AWS key for the certificate challenge record. | approved | |
| +| DBX-C84 | infra/devbox/README.md | The service reads this file itself, because every account can read a plist. | approved | |
| +| DBX-C85 | infra/devbox/README.md | Install the carlos binary and the plist. | approved | |
| +| DBX-C86 | infra/devbox/README.md | In the plist, replace 100.64.0.10 with this Mac's tailnet address, the same one as in CARLOS_DEVBOX_LISTEN. | approved | |
| +| DBX-C87 | infra/devbox/README.md | The service refuses to start if launchd hands it a socket on any other address. | approved | |
| +| DBX-C88 | infra/devbox/README.md | Create the IAM user, key and policy as in the Linux steps above, then load the service. | approved | |
| +| DBX-C89 | infra/devbox/README.md | If the tailnet is not up when launchd loads the service, launchd cannot bind the address. | approved | |
| +| DBX-C90 | infra/devbox/README.md | Once the tailnet is up, start the service again. | approved | |
| +| DBX-C91 | infra/devbox/README.md | Then add the DNS record and run the checks below. | approved | |
| +| DBX-C92 | infra/devbox/README.md | On a Mac, use lsof instead of ss to see what is listening, and read the log file instead of journalctl. | approved | |
diff --git a/infra/devbox/README.md b/infra/devbox/README.md| index fa9671799..a8ffe7bd2 100644 |
| --- a/infra/devbox/README.md |
| +++ b/infra/devbox/README.md |
| @@ -54,6 +54,95 @@ systemctl enable --now carlos-devbox |
| journalctl -u carlos-devbox -f |
| ``` |
| +## Install on macOS, once, as root |
| + |
| +On a Mac, launchd binds port 443 on the tailnet address as root and hands the open socket to the service. The service runs as its own user, so no carlos process runs as root. Follow these steps instead of the Linux ones above. |
| + |
| +Create the service user and its group, both called _carlos-devbox. It is a hidden account with no login and no home folder. |
| + |
| +Give both the same ID, a number below 500 that no user or group has yet. The commands below use 451. |
| + |
| +```sh |
| +dscl . -list /Users UniqueID | sort -n -k2 |
| +dscl . -list /Groups PrimaryGroupID | sort -n -k2 |
| + |
| +dscl . -create /Groups/_carlos-devbox |
| +dscl . -create /Groups/_carlos-devbox PrimaryGroupID 451 |
| +dscl . -create /Groups/_carlos-devbox RealName "carlos devbox" |
| +dscl . -create /Users/_carlos-devbox |
| +dscl . -create /Users/_carlos-devbox UniqueID 451 |
| +dscl . -create /Users/_carlos-devbox PrimaryGroupID 451 |
| +dscl . -create /Users/_carlos-devbox RealName "carlos devbox" |
| +dscl . -create /Users/_carlos-devbox UserShell /usr/bin/false |
| +dscl . -create /Users/_carlos-devbox NFSHomeDirectory /var/empty |
| +dscl . -create /Users/_carlos-devbox Password '*' |
| +dscl . -create /Users/_carlos-devbox IsHidden 1 |
| +``` |
| + |
| +Create the service's folders: one for its data, private to the service user, and one for the registrar socket, which every account can reach. Create the log file as well, owned by the service user. |
| + |
| +```sh |
| +install -d -m 0700 -o _carlos-devbox -g _carlos-devbox /usr/local/var/carlos-devbox |
| +install -d -m 0755 -o _carlos-devbox -g _carlos-devbox /usr/local/var/run/carlos-devbox |
| +install -d -m 0755 /usr/local/var/log |
| +touch /usr/local/var/log/carlos-devbox.log |
| +chown _carlos-devbox:_carlos-devbox /usr/local/var/log/carlos-devbox.log |
| +chmod 0640 /usr/local/var/log/carlos-devbox.log |
| +``` |
| + |
| +Write the environment file, private to the service user. It holds this Mac's tailnet address, the devbox domain, the data folder and the AWS key for the certificate challenge record. The service reads this file itself, because every account can read a plist. |
| + |
| +```sh |
| +install -d -m 0750 -o root -g _carlos-devbox /usr/local/etc/carlos-devbox |
| +touch /usr/local/etc/carlos-devbox/env |
| +chown _carlos-devbox:_carlos-devbox /usr/local/etc/carlos-devbox/env |
| +chmod 0600 /usr/local/etc/carlos-devbox/env |
| +"${EDITOR:-vi}" /usr/local/etc/carlos-devbox/env |
| +``` |
| + |
| +```sh |
| +# /usr/local/etc/carlos-devbox/env |
| +CARLOS_DEVBOX_LISTEN=100.64.0.10:443 |
| +CARLOS_DEVBOX_DOMAIN=devbox.example.com |
| +CARLOS_WILDCARD_DOMAINS=devbox.example.com |
| +CARLOS_DATA_DIR=/usr/local/var/carlos-devbox |
| +CARLOS_DNS_PROVIDER=route53 |
| +AWS_ACCESS_KEY_ID=AKIA... |
| +AWS_SECRET_ACCESS_KEY=... |
| +``` |
| + |
| +Install the carlos binary and the plist. In the plist, replace 100.64.0.10 with this Mac's tailnet address, the same one as in CARLOS_DEVBOX_LISTEN. The service refuses to start if launchd hands it a socket on any other address. |
| + |
| +```sh |
| +install -d -m 0755 /usr/local/bin |
| +install -m 0755 carlos /usr/local/bin/carlos |
| +install -m 0644 -o root -g wheel infra/devbox/com.carlosframework.devbox.plist \ |
| + /Library/LaunchDaemons/com.carlosframework.devbox.plist |
| +TAILNET_IP=100.64.0.10 |
| +sed -i '' "s/100\.64\.0\.10/$TAILNET_IP/" /Library/LaunchDaemons/com.carlosframework.devbox.plist |
| +``` |
| + |
| +Create the IAM user, key and policy as in the Linux steps above, then load the service. |
| + |
| +```sh |
| +launchctl bootstrap system /Library/LaunchDaemons/com.carlosframework.devbox.plist |
| +tail -f /usr/local/var/log/carlos-devbox.log |
| +``` |
| + |
| +If the tailnet is not up when launchd loads the service, launchd cannot bind the address. Once the tailnet is up, start the service again. |
| + |
| +```sh |
| +launchctl kickstart -k system/com.carlosframework.devbox |
| +``` |
| + |
| +Then add the DNS record and run the checks below. On a Mac, use lsof instead of ss to see what is listening, and read the log file instead of journalctl. |
| + |
| +```sh |
| +ls /usr/local/var/carlos-devbox/certs |
| +grep -i acme /usr/local/var/log/carlos-devbox.log |
| +lsof -nP -iTCP -sTCP:LISTEN | grep carlos |
| +``` |
| + |
| ## DNS |
| Add one A record, by hand, once: *.devbox.example.com pointing at this machine's tailnet IPv4 address. |
diff --git a/infra/devbox/com.carlosframework.devbox.plist b/infra/devbox/com.carlosframework.devbox.plist| new file mode 100644 |
| index 000000000..e0668ed9b |
| --- /dev/null |
| +++ b/infra/devbox/com.carlosframework.devbox.plist |
| @@ -0,0 +1,68 @@ |
| +<?xml version="1.0" encoding="UTF-8"?> |
| +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| +<!-- |
| + Devbox mode on macOS (#488): the LaunchDaemon for `carlos devbox serve`. |
| + launchd, as root, binds the tailnet address on port 443 (Sockets) and |
| + starts the service as _carlos-devbox, which takes that socket |
| + (CARLOS_DEVBOX_LAUNCHD_SOCKET names the entry). Nothing of ours runs as |
| + root. Install: infra/devbox/README.md, "Install on macOS". |
| + |
| + Every account can read this file, so it holds no secret. The settings |
| + and the DNS credential are in the env file, mode 0600, which the service |
| + reads itself (its env-file flag, below). |
| + |
| + Replace 100.64.0.10 with this Mac's tailnet address, the same one as |
| + CARLOS_DEVBOX_LISTEN in the env file: the service refuses a socket on any |
| + other address. |
| +--> |
| +<plist version="1.0"> |
| +<dict> |
| + <key>Label</key> |
| + <string>com.carlosframework.devbox</string> |
| + |
| + <key>ProgramArguments</key> |
| + <array> |
| + <string>/usr/local/bin/carlos</string> |
| + <string>devbox</string> |
| + <string>serve</string> |
| + <string>--env-file</string> |
| + <string>/usr/local/etc/carlos-devbox/env</string> |
| + </array> |
| + |
| + <key>UserName</key> |
| + <string>_carlos-devbox</string> |
| + <key>GroupName</key> |
| + <string>_carlos-devbox</string> |
| + |
| + <key>Sockets</key> |
| + <dict> |
| + <key>Listeners</key> |
| + <dict> |
| + <key>SockNodeName</key> |
| + <string>100.64.0.10</string> |
| + <key>SockServiceName</key> |
| + <string>443</string> |
| + <key>SockType</key> |
| + <string>stream</string> |
| + <key>SockFamily</key> |
| + <string>IPv4</string> |
| + </dict> |
| + </dict> |
| + |
| + <key>EnvironmentVariables</key> |
| + <dict> |
| + <key>CARLOS_DEVBOX_LAUNCHD_SOCKET</key> |
| + <string>Listeners</string> |
| + </dict> |
| + |
| + <key>RunAtLoad</key> |
| + <true/> |
| + <key>KeepAlive</key> |
| + <true/> |
| + |
| + <key>StandardOutPath</key> |
| + <string>/usr/local/var/log/carlos-devbox.log</string> |
| + <key>StandardErrorPath</key> |
| + <string>/usr/local/var/log/carlos-devbox.log</string> |
| +</dict> |
| +</plist> |