MCPcopy Index your code
hub / github.com/jetify-com/devbox / newPackage

Function newPackage

internal/devpkg/package.go:135–165  ·  view source on GitHub ↗
(raw string, isInstallable func() bool, locker lock.Locker)

Source from the content-addressed store, hash-verified

133}
134
135func newPackage(raw string, isInstallable func() bool, locker lock.Locker) *Package {
136 pkg := &Package{
137 Raw: raw,
138 lockfile: locker,
139 isInstallable: sync.OnceValue(isInstallable),
140 }
141
142 // The raw string is either a Devbox package ("name" or "name@version")
143 // or it's a flake installable. In some cases they're ambiguous
144 // ("nixpkgs" is a devbox package and a flake). When that happens, we
145 // assume a Devbox package.
146 parsed, err := flake.ParseInstallable(raw)
147 if err != nil || pkgtype.IsAmbiguous(raw, parsed) {
148 // TODO: This sets runx packages as devbox packages. Not sure if that's what we want.
149 pkg.IsDevboxPackage = true
150 pkg.resolve = sync.OnceValue(func() error { return resolve(pkg) })
151 return pkg
152 }
153
154 pkg.resolve = sync.OnceValue(func() error {
155 // Don't lock flakes that are local paths.
156 if parsed.Ref.Type == flake.TypePath {
157 return nil
158 }
159 return resolve(pkg)
160 })
161 pkg.setInstallable(parsed, locker.ProjectDir())
162 pkg.outputs = outputs{selectedNames: strings.Split(parsed.Outputs, ",")}
163 pkg.Patch = pkgNeedsPatch(pkg.CanonicalName(), configfile.PatchAuto)
164 return pkg
165}
166
167// resolve is the implementation of Package.resolve, where it is wrapped in a
168// sync.OnceValue function. It should not be called directly.

Callers 2

PackagesFromConfigFunction · 0.85

Calls 7

setInstallableMethod · 0.95
CanonicalNameMethod · 0.95
ParseInstallableFunction · 0.92
IsAmbiguousFunction · 0.92
resolveFunction · 0.85
pkgNeedsPatchFunction · 0.85
ProjectDirMethod · 0.65

Tested by

no test coverage detected