(pkg *searcher.PackageVersion)
| 166 | } |
| 167 | |
| 168 | func 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 | |
| 214 | func lockFlake(ctx context.Context, ref flake.Ref, refresh bool) (flake.Ref, error) { |
| 215 | if ref.Locked() { |
no test coverage detected