Repository navigation
feat(pkgdef): wire package definitions into add, lock, install and env - #3002
Open
mikeland73 wants to merge 1 commit into
Open
mikeland73 wants to merge 1 commit into
mikeland73 wants to merge 1 commit into
Conversation
Teach Devbox the "pkg:<ref>@<version>" package string behind the DEVBOX_FEATURE_PKG_DEFS flag (on in dev builds). See specs/package-definitions.md. - pkgtype.IsPkgDef recognizes the scheme and keeps it out of flake detection; devpkg treats such packages as non-nix so shellgen and the nix store paths skip them, and ValidateExists resolves them through the lockfile so `devbox add` surfaces the definition's own errors. - devbox.lock gains definition_hash and per-system url/sha256. Remote definitions are pinned to the hash except on `devbox update`; a definition without a checksum source gets its digest recorded by the first install (trust on first use) and kept across updates. - installPackages installs package definitions next to runx packages into $XDG_CACHE_HOME/devbox/pkgs and computeEnv appends their bin directories to PATH. A definition that does not support the current system fails with an --exclude-platform hint. - Each resolved package definition becomes a plugin config so its env, shell.init_hook and create_files apply through the plugin manager, with InstallDir, Version, CacheDir, System, OS and Arch template variables. Local definition files feed the config hash so edits trigger a reinstall. - Relative file:// URLs in a local definition resolve against its directory, which keeps the new testscript self-contained. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Third PR of the package definitions stack. Teaches Devbox the
pkg:<ref>@<version>package string, behind theDEVBOX_FEATURE_PKG_DEFSflag (on in dev builds). While the flag is off,pkg:strings are not recognized at all.DEVBOX_FEATURE_PKG_DEFS=1 devbox add pkg:./go.pkg.json@1.22 devbox run -- go version # go version go1.22.12 darwin/arm64, from go.devpkgtype.IsPkgDefrecognizes the scheme and keeps it out of flake detection.devpkgtreats such packages as non-nix (shellgen and the nix store paths skip them), splits name and version at the last@, and resolves them through the lockfile sodevbox addsurfaces the definition's own errors instead of falling back to nixpkgs.devbox.lockgainsdefinition_hashand per-systemurl/sha256(additive,lockfile_versionunchanged). Remote definitions stay pinned to the hash except ondevbox update, which also records a changed hash when version and artifacts are unchanged. A definition without a checksum source gets its digest recorded by the first install (trust on first use), only from the install path, never while computing the environment.installPackagesinstalls package definitions next to runx packages;computeEnvappends their bin directories toPATH. Unsupported system fails with an--exclude-platformhint. Relativefile://URLs stay relative in the lockfile and resolve against the definition's directory when fetching, so lockfiles are portable.pkgdef-<name>), soenv,shell.init_hookandcreate_filesapply through the plugin manager withInstallDir,Version,CacheDir,System,OSandArchtemplate variables. A definition that cannot be loaded does not block config loading, sodevbox updateanddevbox rmalways work.The spec's status table is updated accordingly.
Test plan
testscripts/pkgdef/pkgdef.test.txt: add with a version prefix, lockfile contents, binary on PATH, env/init hook/create_files templating, version switch, unknown version error, removeinternal/pkgdef,internal/devpkg,internal/devbox(update merge records a changed definition hash),internal/plugin,internal/devconfigpkgs/go/go.pkg.jsonon macOS arm64 installs Go 1.22.12 from go.dev with all four platform checksums locked;which goandgo env GOROOTpoint into the cachegolangci-lint ./...and gofumpt clean🤖 Generated with Claude Code