@@ -91,11 +91,11 @@ func (p *Package) isLocal() bool {
9191 return p .Scheme == "path"
9292}
9393
94- // isDevboxPackage specifies whether this package is a devbox package. Devbox
94+ // IsDevboxPackage specifies whether this package is a devbox package. Devbox
9595// packages have the format `canonicalName@version`and can be resolved by devbox
9696// search. This also returns true for legacy packages which are just an
9797// attribute path. An explicit flake reference is _not_ a devbox package.
98- func (p * Package ) isDevboxPackage () bool {
98+ func (p * Package ) IsDevboxPackage () bool {
9999 return p .Scheme == ""
100100}
101101
@@ -135,7 +135,7 @@ func (p *Package) FlakeInputName() string {
135135// URLForFlakeInput returns the input url to be used in a flake.nix file. This
136136// input can be used to import the package.
137137func (p * Package ) URLForFlakeInput () string {
138- if p .isDevboxPackage () {
138+ if p .IsDevboxPackage () {
139139 entry , err := p .lockfile .Resolve (p .Raw )
140140 if err != nil {
141141 panic (err )
@@ -175,7 +175,7 @@ func (p *Package) Installable() (string, error) {
175175// The key difference with URLForFlakeInput is that it has a suffix of
176176// `#attributePath`
177177func (p * Package ) urlForInstall () (string , error ) {
178- if p .isDevboxPackage () {
178+ if p .IsDevboxPackage () {
179179 entry , err := p .lockfile .Resolve (p .Raw )
180180 if err != nil {
181181 return "" , err
@@ -190,7 +190,7 @@ func (p *Package) urlForInstall() (string, error) {
190190}
191191
192192func (p * Package ) NormalizedDevboxPackageReference () (string , error ) {
193- if ! p .isDevboxPackage () {
193+ if ! p .IsDevboxPackage () {
194194 return "" , nil
195195 }
196196
@@ -201,7 +201,7 @@ func (p *Package) NormalizedDevboxPackageReference() (string, error) {
201201 return "" , err
202202 }
203203 path = entry .Resolved
204- } else if p .isDevboxPackage () {
204+ } else if p .IsDevboxPackage () {
205205 path = p .lockfile .LegacyNixpkgsPath (p .String ())
206206 }
207207
@@ -220,7 +220,7 @@ func (p *Package) NormalizedDevboxPackageReference() (string, error) {
220220// PackageAttributePath returns the short attribute path for a package which
221221// does not include packages/legacyPackages or the system name.
222222func (p * Package ) PackageAttributePath () (string , error ) {
223- if p .isDevboxPackage () {
223+ if p .IsDevboxPackage () {
224224 entry , err := p .lockfile .Resolve (p .Raw )
225225 if err != nil {
226226 return "" , err
@@ -236,7 +236,7 @@ func (p *Package) PackageAttributePath() (string, error) {
236236// During happy paths (devbox packages and nix flakes that contains a fragment)
237237// it is much faster than NormalizedPackageAttributePath
238238func (p * Package ) FullPackageAttributePath () (string , error ) {
239- if p .isDevboxPackage () {
239+ if p .IsDevboxPackage () {
240240 reference , err := p .NormalizedDevboxPackageReference ()
241241 if err != nil {
242242 return "" , err
@@ -266,7 +266,7 @@ func (p *Package) NormalizedPackageAttributePath() (string, error) {
266266// path. It is an expensive call (~100ms).
267267func (p * Package ) normalizePackageAttributePath () (string , error ) {
268268 var query string
269- if p .isDevboxPackage () {
269+ if p .IsDevboxPackage () {
270270 if p .isVersioned () {
271271 entry , err := p .lockfile .Resolve (p .Raw )
272272 if err != nil {
@@ -282,7 +282,7 @@ func (p *Package) normalizePackageAttributePath() (string, error) {
282282
283283 // We prefer search over just trying to parse the URL because search will
284284 // guarantee that the package exists for the current system.
285- infos := nix .Search (query )
285+ infos , _ := nix .Search (query )
286286
287287 if len (infos ) == 1 {
288288 return lo .Keys (infos )[0 ], nil
@@ -349,23 +349,6 @@ func (p *Package) Hash() string {
349349 return shortHash
350350}
351351
352- func (p * Package ) ValidateExists () (bool , error ) {
353- if p .isVersioned () && p .version () == "" {
354- return false , usererr .New ("No version specified for %q." , p .Path )
355- }
356-
357- inCache , err := p .IsInBinaryCache ()
358- if err != nil {
359- return false , err
360- }
361- if inCache {
362- return true , nil
363- }
364-
365- info , err := p .NormalizedPackageAttributePath ()
366- return info != "" , err
367- }
368-
369352func (p * Package ) Equals (other * Package ) bool {
370353 if p .String () == other .String () {
371354 return true
@@ -390,22 +373,22 @@ func (p *Package) Equals(other *Package) bool {
390373// CanonicalName returns the name of the package without the version
391374// it only applies to devbox packages
392375func (p * Package ) CanonicalName () string {
393- if ! p .isDevboxPackage () {
376+ if ! p .IsDevboxPackage () {
394377 return ""
395378 }
396379 name , _ , _ := strings .Cut (p .Path , "@" )
397380 return name
398381}
399382
400383func (p * Package ) Versioned () string {
401- if p .isDevboxPackage () && ! p .isVersioned () {
384+ if p .IsDevboxPackage () && ! p .isVersioned () {
402385 return p .Raw + "@latest"
403386 }
404387 return p .Raw
405388}
406389
407390func (p * Package ) IsLegacy () bool {
408- return p .isDevboxPackage () && ! p .isVersioned () && p .lockfile .Get (p .Raw ).GetSource () == ""
391+ return p .IsDevboxPackage () && ! p .isVersioned () && p .lockfile .Get (p .Raw ).GetSource () == ""
409392}
410393
411394func (p * Package ) LegacyToVersioned () string {
@@ -437,15 +420,15 @@ func (p *Package) EnsureNixpkgsPrefetched(w io.Writer) error {
437420// version returns the version of the package
438421// it only applies to devbox packages
439422func (p * Package ) version () string {
440- if ! p .isDevboxPackage () {
423+ if ! p .IsDevboxPackage () {
441424 return ""
442425 }
443426 _ , version , _ := strings .Cut (p .Path , "@" )
444427 return version
445428}
446429
447430func (p * Package ) isVersioned () bool {
448- return p .isDevboxPackage () && strings .Contains (p .Path , "@" )
431+ return p .IsDevboxPackage () && strings .Contains (p .Path , "@" )
449432}
450433
451434func (p * Package ) HashFromNixPkgsURL () string {
0 commit comments