Documentation
¶
Overview ¶
Package nixhome locates the nixhome flake (upstream devcell-sh/home by default, or a DEVCELL_NIXHOME override) and reads its devcellModules catalog. It is engine-independent.
Index ¶
- Constants
- func CatalogPath(version string) string
- func FormatModuleCounts(counts []ModuleCount) string
- func FormatPackageSummary(counts []ModuleCount) string
- func PreflightPlatformCheck(ctx context.Context, nixhomeFlakeRef, targetSystem string) error
- func PreflightPlatformCheckWithLookPath(ctx context.Context, nixhomeFlakeRef, targetSystem string, ...) error
- func ReadFullCatalogFromFlake(ctx context.Context, flakeRef string) ([]byte, error)
- func ResolveNixhomeRef(ver string) string
- func SplitCatalog(raw []byte) (map[string][]byte, error)
- func UpstreamFlakeRef(ref string) string
- func UpstreamFlakeRefNoVersion() string
- type Catalog
- type ModuleCount
- type ModuleMeta
- type PackageDefinition
Constants ¶
const ( UpstreamOwner = "devcell-sh" UpstreamRepo = "home" // UpstreamSubdir is empty since the nixhome moved to its own repo // (devcell-sh/home); the flake now lives at the repo root. UpstreamSubdir = "" )
Canonical upstream nixhome source — single source of truth across the CLI. Centralised here so a fork/rename is a one-line change.
const DefaultNixhomeGitRef = "main"
DefaultNixhomeGitRef is the github branch/tag used when no local nixhome is available and the cell binary doesn't carry a release version (v0.0.0 / dev builds). Points at the devcell-sh/home repo's default branch.
Variables ¶
This section is empty.
Functions ¶
func CatalogPath ¶
CatalogPath is the site path under which the home flake's catalog is published for one schema version: https://devcell.sh/schema/<version>/devcell-sh/home/{modules,stacks,packages}.json. The org/repo segment mirrors the flake's GitHub location so other homes can publish alongside it. Mirrored on disk under web/public/.
func FormatModuleCounts ¶
func FormatModuleCounts(counts []ModuleCount) string
FormatModuleCounts renders the counts inline, without a heading:
desktop: 69, base: 35, infra: 11
This is what the thin image's devcell.packages label carries.
func FormatPackageSummary ¶
func FormatPackageSummary(counts []ModuleCount) string
FormatPackageSummary renders one inline line for the build log:
Packages: desktop: 69, base: 35, infra: 11
func PreflightPlatformCheck ¶
PreflightPlatformCheck runs `nix eval` on the flake's platformStrictCheck attribute to verify that all packages (including transitive dependencies) are compatible with the target system. Returns nil on success.
Skips gracefully (returns nil) when nix is not in PATH — this allows the thin Docker build path to work on hosts without nix installed.
targetSystem is a nix system string like "aarch64-linux" or "aarch64-darwin".
func PreflightPlatformCheckWithLookPath ¶
func PreflightPlatformCheckWithLookPath(ctx context.Context, nixhomeFlakeRef, targetSystem string, lookPath func(string) (string, error)) error
PreflightPlatformCheckWithLookPath is the testable seam — tests inject a custom lookPath to simulate nix-not-found without modifying PATH.
func ReadFullCatalogFromFlake ¶
ReadFullCatalogFromFlake invokes `nix eval --json <flakeRef>#devcellCatalog` and returns the raw JSON for SplitCatalog.
func ResolveNixhomeRef ¶
ResolveNixhomeRef returns the nixhome source to use for builds. Precedence: DEVCELL_NIXHOME > DEVCELL_NIXHOME_PATH (legacy) > default upstream flake ref. Accepts local paths, github: flake refs, or https:// git URLs.
func SplitCatalog ¶
SplitCatalog turns the raw devcellCatalog JSON into the three published documents, keyed by file name:
- modules.json: module name → {description, mcpServers, sizeMb}
- stacks.json: stack name → {modules: [names], packages: [names]}
- packages.json: package name → {version, stacks: [names that ship it]}
packages.json is the inverted index: it answers "is X already in my stack" without scanning every stack entry. Home-manager's internal derivations are dropped from both package views.
func UpstreamFlakeRef ¶
UpstreamFlakeRef returns the canonical github flake reference for the devcell nixhome, pinned to `ref`. Empty / "v0.0.0" / dev-version coerces to DefaultNixhomeGitRef so dev builds always point at a real branch.
Example: UpstreamFlakeRef("v1.0.0") → "github:devcell-sh/home/v1.0.0"
func UpstreamFlakeRefNoVersion ¶
func UpstreamFlakeRefNoVersion() string
UpstreamFlakeRefNoVersion returns the unpinned ref — used by introspection commands (`cell modules list`) that want the catalog as it exists upstream right now, not pinned to the CLI binary's compile-time version.
Types ¶
type Catalog ¶
type Catalog map[string]ModuleMeta
Catalog is the full catalog keyed by module name (e.g. "electronics", "yahoo-finance").
func ParseCatalogJSON ¶
ParseCatalogJSON decodes raw JSON output from `nix eval .#devcellModules --json` into a typed Catalog. Returns an error if the JSON is malformed.
func ReadCatalogFromFlake ¶
ReadCatalogFromFlake invokes `nix eval --json <flakeRef>#devcellModules` and parses the result. `flakeRef` is something like `path:./nixhome` or `github:devcell/modules?ref=v1.0`.
Returns an error if the nix subprocess fails or the JSON is malformed. The CLI wraps this error with user-language guidance in cmd/.
type ModuleCount ¶
ModuleCount is the number of packages one devcell module contributes.
func GroupPackageDefinitions ¶
func GroupPackageDefinitions(defs []PackageDefinition, hmDeclaration string) []ModuleCount
GroupPackageDefinitions counts packages per devcell module. The module is the first path component under modules/ with its .nix suffix dropped, so modules/llm/claude.nix and modules/llm/codex.nix both count as llm. Definitions from home-manager's own tree (identified by hmDeclaration, the file declaring home.packages) are left out: users cannot toggle them. Definitions with no file, such as packages inlined in the overlay flake, count as "config". Sorted by count descending, then name.
type ModuleMeta ¶
type ModuleMeta struct {
Description string `json:"description"`
MCPServers []string `json:"mcpServers"`
SizeMB int `json:"sizeMb"`
}
ModuleMeta is one entry from the `devcellModules` flake catalog. Mirrors the shape of `nix eval .#devcellModules --json`.
type PackageDefinition ¶
PackageDefinition is one home.packages assignment: the module file that made it and the packages it contributed. Mirrors home-manager's options.home.packages.definitionsWithLocations.
func EvalPackageDefinitions ¶
func EvalPackageDefinitions(ctx context.Context, flakeRef, homeConfig string) ([]PackageDefinition, string, error)
EvalPackageDefinitions evaluates the home.packages definitions of one homeConfiguration in flakeRef. Returns nil, "", nil when nix is not in PATH so the docker build path keeps working on hosts without nix.
func ParsePackageEval ¶
func ParsePackageEval(raw []byte) ([]PackageDefinition, string, error)
ParsePackageEval decodes the JSON produced by packageEvalExpr.