MCPcopy
hub / github.com/jetify-com/devbox / sysInfoIfExists

Method sysInfoIfExists

internal/devpkg/narinfo_cache.go:230–255  ·  view source on GitHub ↗

sysInfoIfExists returns the system info for the user's system. If the sysInfo is missing, then nil is returned NOTE: this is called from multiple go-routines and needs to be concurrency safe. Hence, we compute nix.Version, nix.System and lockfile.Resolve prior to calling this function from within a

()

Source from the content-addressed store, hash-verified

228// Hence, we compute nix.Version, nix.System and lockfile.Resolve prior to calling this
229// function from within a goroutine.
230func (p *Package) sysInfoIfExists() (*lock.SystemInfo, error) {
231 if !p.isVersioned() {
232 return nil, nil
233 }
234
235 // disable for nix < 2.17
236 if !nix.AtLeast(nix.Version2_17) {
237 return nil, nil
238 }
239
240 entry, err := p.lockfile.Resolve(p.Raw)
241 if err != nil {
242 return nil, err
243 }
244
245 if entry.Systems == nil {
246 return nil, nil
247 }
248
249 // Check if the user's system's info is present in the lockfile
250 sysInfo, ok := entry.Systems[nix.System()]
251 if !ok {
252 return nil, nil
253 }
254 return sysInfo, nil
255}
256
257var narInfoStatusFnCache = sync.Map{}
258

Callers 3

outputsForOutputNameMethod · 0.95
initDefaultNamesMethod · 0.80

Calls 4

isVersionedMethod · 0.95
AtLeastFunction · 0.92
SystemFunction · 0.92
ResolveMethod · 0.65

Tested by

no test coverage detected