()
| 458 | var ErrCannotBuildPackageOnSystem = errors.New("unable to build for system") |
| 459 | |
| 460 | func (p *Package) Hash() string { |
| 461 | sum := "" |
| 462 | if p.installable.Ref.Type == flake.TypePath { |
| 463 | // For local flakes, use content hash of the flake.nix file to ensure |
| 464 | // user always gets newest flake. |
| 465 | sum, _ = cachehash.File(filepath.Join(p.installable.Ref.Path, "flake.nix")) |
| 466 | } |
| 467 | |
| 468 | if sum == "" { |
| 469 | sum = cachehash.Bytes([]byte(cmp.Or(p.installable.String(), p.Raw))) |
| 470 | } |
| 471 | return sum[:min(len(sum), 6)] |
| 472 | } |
| 473 | |
| 474 | // Equals compares two Packages. This may be an expensive operation since it |
| 475 | // may have to normalize a Package's attribute path, which may require a network |
no test coverage detected