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
()
| 228 | // Hence, we compute nix.Version, nix.System and lockfile.Resolve prior to calling this |
| 229 | // function from within a goroutine. |
| 230 | func (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 | |
| 257 | var narInfoStatusFnCache = sync.Map{} |
| 258 |
no test coverage detected