@@ -91,11 +91,11 @@ func (p *Package) isLocal() bool {
91
91
return p .Scheme == "path"
92
92
}
93
93
94
- // isDevboxPackage specifies whether this package is a devbox package. Devbox
94
+ // IsDevboxPackage specifies whether this package is a devbox package. Devbox
95
95
// packages have the format `canonicalName@version`and can be resolved by devbox
96
96
// search. This also returns true for legacy packages which are just an
97
97
// attribute path. An explicit flake reference is _not_ a devbox package.
98
- func (p * Package ) isDevboxPackage () bool {
98
+ func (p * Package ) IsDevboxPackage () bool {
99
99
return p .Scheme == ""
100
100
}
101
101
@@ -135,7 +135,7 @@ func (p *Package) FlakeInputName() string {
135
135
// URLForFlakeInput returns the input url to be used in a flake.nix file. This
136
136
// input can be used to import the package.
137
137
func (p * Package ) URLForFlakeInput () string {
138
- if p .isDevboxPackage () {
138
+ if p .IsDevboxPackage () {
139
139
entry , err := p .lockfile .Resolve (p .Raw )
140
140
if err != nil {
141
141
panic (err )
@@ -175,7 +175,7 @@ func (p *Package) Installable() (string, error) {
175
175
// The key difference with URLForFlakeInput is that it has a suffix of
176
176
// `#attributePath`
177
177
func (p * Package ) urlForInstall () (string , error ) {
178
- if p .isDevboxPackage () {
178
+ if p .IsDevboxPackage () {
179
179
entry , err := p .lockfile .Resolve (p .Raw )
180
180
if err != nil {
181
181
return "" , err
@@ -190,7 +190,7 @@ func (p *Package) urlForInstall() (string, error) {
190
190
}
191
191
192
192
func (p * Package ) NormalizedDevboxPackageReference () (string , error ) {
193
- if ! p .isDevboxPackage () {
193
+ if ! p .IsDevboxPackage () {
194
194
return "" , nil
195
195
}
196
196
@@ -201,7 +201,7 @@ func (p *Package) NormalizedDevboxPackageReference() (string, error) {
201
201
return "" , err
202
202
}
203
203
path = entry .Resolved
204
- } else if p .isDevboxPackage () {
204
+ } else if p .IsDevboxPackage () {
205
205
path = p .lockfile .LegacyNixpkgsPath (p .String ())
206
206
}
207
207
@@ -220,7 +220,7 @@ func (p *Package) NormalizedDevboxPackageReference() (string, error) {
220
220
// PackageAttributePath returns the short attribute path for a package which
221
221
// does not include packages/legacyPackages or the system name.
222
222
func (p * Package ) PackageAttributePath () (string , error ) {
223
- if p .isDevboxPackage () {
223
+ if p .IsDevboxPackage () {
224
224
entry , err := p .lockfile .Resolve (p .Raw )
225
225
if err != nil {
226
226
return "" , err
@@ -236,7 +236,7 @@ func (p *Package) PackageAttributePath() (string, error) {
236
236
// During happy paths (devbox packages and nix flakes that contains a fragment)
237
237
// it is much faster than NormalizedPackageAttributePath
238
238
func (p * Package ) FullPackageAttributePath () (string , error ) {
239
- if p .isDevboxPackage () {
239
+ if p .IsDevboxPackage () {
240
240
reference , err := p .NormalizedDevboxPackageReference ()
241
241
if err != nil {
242
242
return "" , err
@@ -266,7 +266,7 @@ func (p *Package) NormalizedPackageAttributePath() (string, error) {
266
266
// path. It is an expensive call (~100ms).
267
267
func (p * Package ) normalizePackageAttributePath () (string , error ) {
268
268
var query string
269
- if p .isDevboxPackage () {
269
+ if p .IsDevboxPackage () {
270
270
if p .isVersioned () {
271
271
entry , err := p .lockfile .Resolve (p .Raw )
272
272
if err != nil {
@@ -282,7 +282,7 @@ func (p *Package) normalizePackageAttributePath() (string, error) {
282
282
283
283
// We prefer search over just trying to parse the URL because search will
284
284
// guarantee that the package exists for the current system.
285
- infos := nix .Search (query )
285
+ infos , _ := nix .Search (query )
286
286
287
287
if len (infos ) == 1 {
288
288
return lo .Keys (infos )[0 ], nil
@@ -349,23 +349,6 @@ func (p *Package) Hash() string {
349
349
return shortHash
350
350
}
351
351
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
-
369
352
func (p * Package ) Equals (other * Package ) bool {
370
353
if p .String () == other .String () {
371
354
return true
@@ -390,22 +373,22 @@ func (p *Package) Equals(other *Package) bool {
390
373
// CanonicalName returns the name of the package without the version
391
374
// it only applies to devbox packages
392
375
func (p * Package ) CanonicalName () string {
393
- if ! p .isDevboxPackage () {
376
+ if ! p .IsDevboxPackage () {
394
377
return ""
395
378
}
396
379
name , _ , _ := strings .Cut (p .Path , "@" )
397
380
return name
398
381
}
399
382
400
383
func (p * Package ) Versioned () string {
401
- if p .isDevboxPackage () && ! p .isVersioned () {
384
+ if p .IsDevboxPackage () && ! p .isVersioned () {
402
385
return p .Raw + "@latest"
403
386
}
404
387
return p .Raw
405
388
}
406
389
407
390
func (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 () == ""
409
392
}
410
393
411
394
func (p * Package ) LegacyToVersioned () string {
@@ -437,15 +420,15 @@ func (p *Package) EnsureNixpkgsPrefetched(w io.Writer) error {
437
420
// version returns the version of the package
438
421
// it only applies to devbox packages
439
422
func (p * Package ) version () string {
440
- if ! p .isDevboxPackage () {
423
+ if ! p .IsDevboxPackage () {
441
424
return ""
442
425
}
443
426
_ , version , _ := strings .Cut (p .Path , "@" )
444
427
return version
445
428
}
446
429
447
430
func (p * Package ) isVersioned () bool {
448
- return p .isDevboxPackage () && strings .Contains (p .Path , "@" )
431
+ return p .IsDevboxPackage () && strings .Contains (p .Path , "@" )
449
432
}
450
433
451
434
func (p * Package ) HashFromNixPkgsURL () string {
0 commit comments