feat: add manifest profile discovery

This commit is contained in:
2026-05-30 02:18:42 +09:00
parent 06c778a725
commit ee7147b355
8 changed files with 822 additions and 63 deletions
+41 -3
View File
@@ -2,7 +2,7 @@
Manifest profiles are the human-authored Nix entrypoint for generating an Insomnia runtime manifest. The Rust side evaluates a selected profile with `nix eval --json --file <path>`, deserializes the resulting JSON artifact, and validates it through the existing `PodManifest` pipeline.
This keeps composition/import/common logic in Nix. Insomnia does not add an implicit profile cascade or merge TOML profile layers at runtime.
This keeps composition/import/common logic in Nix. Insomnia does not add an implicit profile cascade or merge TOML profile layers into the selected runtime manifest.
## Minimal profile
@@ -27,7 +27,7 @@ insomnia.mkProfile {
}
```
Run it with:
Run an explicit path with:
```sh
insomnia-pod --profile ./coder.nix
@@ -35,7 +35,45 @@ insomnia-pod --profile ./coder.nix
insomnia --profile ./coder.nix
```
`--profile` conflicts with `insomnia-pod --manifest` and with restore/session/adopt modes. Use `--profile-pod-name <name>` when a launcher needs a creation-time Pod name override without invoking `--pod` restore semantics. Profile evaluation is a creation-time path; Pod resume should restore saved Pod state/resolved snapshots rather than re-evaluating the Nix source.
`--profile` accepts an explicit path, `path:<path>`, a discovered profile name, `default`, or a source-qualified name such as `project:coder`, `user:coder`, or `builtin:coder`. Path-like values containing `/`, starting with `.`, or ending in `.nix` preserve the original explicit-path behavior.
`--profile` conflicts with `insomnia-pod --manifest` and with restore/session/adopt modes. Use `--profile-pod-name <name>` when a launcher needs a creation-time Pod name override without invoking `--pod` restore semantics. Profile evaluation is a creation-time path; Pod resume restores saved Pod state/resolved snapshots rather than re-evaluating the Nix source.
## Profile discovery
Profile discovery is separate from runtime manifest merging. User/project TOML files may declare profile registry metadata under `[profiles]`, but those files are not merged into the Nix profile artifact.
Example project config at `.insomnia/manifest.toml`:
```toml
[profiles]
default = "coder"
[profiles.profile]
coder = "profiles/coder.nix"
reviewer = "profiles/reviewer.nix"
[profiles.alias]
work = "project:coder"
```
Table entries can carry descriptions:
```toml
[profiles.profile.coder]
path = "profiles/coder.nix"
description = "Project coding assistant"
```
Relative registry paths are resolved against the TOML file that declares them. Discovery checks builtin profiles, then the user manifest, then the nearest project manifest. Later defaults override earlier defaults, so a project default wins over a user default. Unqualified ambiguous names fail closed:
```sh
insomnia --profile coder # fails if both user:coder and project:coder exist
insomnia --profile project:coder # source-qualified selection
insomnia --profile default # selected registry default
```
The fresh-spawn TUI also uses discovery. If a default profile is configured, the new Pod dialog shows `profile: coder (default)` and spawns with the source-qualified selector. Passing `insomnia --profile <selector>` opens the same new Pod dialog with that selector shown and leaves Pod-name editing unchanged.
## Artifact contract