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

Function buildLockSystemInfos

internal/lock/resolve.go:168–212  ·  view source on GitHub ↗
(pkg *searcher.PackageVersion)

Source from the content-addressed store, hash-verified

166}
167
168func buildLockSystemInfos(pkg *searcher.PackageVersion) (map[string]*SystemInfo, error) {
169 // guard against missing search data
170 systems := lo.PickBy(pkg.Systems, func(sysName string, sysInfo searcher.PackageInfo) bool {
171 return sysInfo.StoreHash != "" && sysInfo.StoreName != ""
172 })
173
174 group, ctx := errgroup.WithContext(context.Background())
175
176 var storePathLock sync.RWMutex
177 sysStorePaths := map[string]string{}
178 for _sysName, _sysInfo := range systems {
179 sysName := _sysName // capture range variable
180 sysInfo := _sysInfo // capture range variable
181
182 group.Go(func() error {
183 // We should use devpkg.BinaryCache here, but it'll cause a circular reference
184 // Just hardcoding for now. Maybe we should move that to nix.DefaultBinaryCache?
185 path, err := nix.StorePathFromHashPart(ctx, sysInfo.StoreHash, "https://cache.nixos.org")
186 if err != nil {
187 // Should we report this to sentry to collect data?
188 slog.Error("failed to resolve store path", "system", sysName, "store_hash", sysInfo.StoreHash, "err", err)
189 // Instead of erroring, we can just skip this package. It can install via the slow path.
190 return nil
191 }
192 storePathLock.Lock()
193 sysStorePaths[sysName] = path
194 storePathLock.Unlock()
195 return nil
196 })
197 }
198 err := group.Wait()
199 if err != nil {
200 return nil, err
201 }
202
203 sysInfos := map[string]*SystemInfo{}
204 for sysName, storePath := range sysStorePaths {
205 sysInfo := &SystemInfo{
206 StorePath: storePath,
207 }
208 sysInfo.addOutputFromLegacyStorePath()
209 sysInfos[sysName] = sysInfo
210 }
211 return sysInfos, nil
212}
213
214func lockFlake(ctx context.Context, ref flake.Ref, refresh bool) (flake.Ref, error) {
215 if ref.Locked() {

Callers 1

FetchResolvedPackageMethod · 0.85

Calls 3

StorePathFromHashPartFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected