scaffold

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const NixhomeSourceFile = ".devcell-source"

NixhomeSourceFile is the metadata file that tracks which source was used to populate .devcell/nixhome/. Used to detect when a different source would overwrite an existing nixhome.

Variables

This section is empty.

Functions

func CopyDir added in v0.4.0

func CopyDir(src, dst string) error

CopyDir recursively copies src directory to dst.

func GenerateDockerfile added in v0.4.0

func GenerateDockerfile(baseImage string) string

GenerateDockerfile produces a Dockerfile string for the .devcell/ build context. baseImage overrides the FROM line; empty uses runner.BaseImageTag().

func GenerateDockerfileWithNixhome added in v0.4.0

func GenerateDockerfileWithNixhome(baseImage string, withNixhome bool, stack string, modules []string) string

GenerateDockerfileWithNixhome produces a Dockerfile with optional nixhome COPY. stack and modules are embedded as ARG defaults for /etc/devcell/metadata.json.

func GenerateFlakeNix added in v0.4.0

func GenerateFlakeNix(stack string, modules []string, ver string, withNixhome bool) string

GenerateFlakeNix produces a flake.nix string that imports the given stack and modules from the upstream devcell nixhome flake. stack is a stack name (e.g. "go"), modules is a list of module names, ver is the version tag, nixhomePath overrides the input URL to path:./nixhome.

func IsGitURL added in v0.4.0

func IsGitURL(source string) bool

IsGitURL returns true if source looks like a git URL or GitHub shorthand.

func IsInitialized

func IsInitialized(dir string) bool

IsInitialized returns true when .devcell.toml exists in dir.

func NixhomeSource added in v0.4.0

func NixhomeSource(configDir string) string

NixhomeSource reads the source origin from .devcell/nixhome/.devcell-source. Returns "" if the file doesn't exist.

func RegenerateBuildContext added in v0.4.0

func RegenerateBuildContext(configDir string, cellCfg cfg.CellConfig) error

RegenerateBuildContext regenerates all build artifacts (flake.nix, Dockerfile, package.json, pyproject.toml) from the merged config. Call before every build so that changes to stack/modules in devcell.toml take effect without re-running cell init.

Cache optimization: when the user picks a known stack, we try to use the pre-built stack image (ghcr.io/dimmkirr/devcell:latest-<stack>) as the FROM line. This lets Docker/nix reuse the existing /nix/store paths from that image — only the delta is downloaded. If the pre-built image isn't available (not yet pushed, network error), we fall back to the core image.

func ResolveNixhome added in v0.4.0

func ResolveNixhome(source, buildDir, ver string, force bool) error

ResolveNixhome pulls nixhome into buildDir/nixhome/ from the given source.

  • Local path: copy directly (rsync-like)
  • Git URL: shallow sparse clone, extract nixhome/ subdir
  • Empty source: clone from upstream repo at the given version tag

Skips if buildDir/nixhome/ already exists and force is false.

func Scaffold

func Scaffold(dir string, modelsSnippet string, nixhomePath string, force bool, stack ...string) error

func ScaffoldVagrantfile

func ScaffoldVagrantfile(dir, vagrantBox, nixhomePath string) error

ScaffoldVagrantfile writes a Vagrantfile to dir substituting:

  • {{VAGRANT_BOX}} with vagrantBox (empty → falls back to MACOS_BOX env var at runtime)
  • {{NIXHOME_PATH}} with nixhomePath (empty → falls back to NIXHOME_PATH env var at runtime)

Skips writing if a Vagrantfile already exists (idempotent).

func ScaffoldWithModules added in v0.4.0

func ScaffoldWithModules(dir string, modelsSnippet string, nixhomePath string, force bool, stack string, modules []string) error

Scaffold writes .devcell.toml to dir (project root) and build artifacts (Dockerfile, flake.nix, package.json, pyproject.toml, starship.toml) to dir/.devcell/ (build context, gitignored). ScaffoldWithModules is like Scaffold but also writes the selected modules list.

func SyncNixhome added in v0.3.0

func SyncNixhome(srcPath, configDir string) error

SyncNixhome copies the nixhome directory from srcPath into configDir/nixhome/. It replaces any existing nixhome copy to ensure fresh content each build. Also removes the outer flake.lock so nix regenerates it from the inner nixhome's inputs — prevents stale lock from pinning different nixpkgs than the base image, which would cause a full re-download. Writes .devcell-source to track the origin.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL