resetProfileDirForFlakes ensures the profileDir directory is cleared of old state if the Flakes feature has been changed, from the previous execution of a devbox command.
(profileDir string)
| 433 | // resetProfileDirForFlakes ensures the profileDir directory is cleared of old |
| 434 | // state if the Flakes feature has been changed, from the previous execution of a devbox command. |
| 435 | func resetProfileDirForFlakes(profileDir string) (err error) { |
| 436 | if resetCheckDone { |
| 437 | return nil |
| 438 | } |
| 439 | defer func() { |
| 440 | if err == nil { |
| 441 | resetCheckDone = true |
| 442 | } |
| 443 | }() |
| 444 | |
| 445 | dir, err := filepath.EvalSymlinks(profileDir) |
| 446 | if errors.Is(err, fs.ErrNotExist) { |
| 447 | return nil |
| 448 | } |
| 449 | if err != nil { |
| 450 | return errors.WithStack(err) |
| 451 | } |
| 452 | |
| 453 | // older nix profiles have a manifest.nix file present |
| 454 | _, err = os.Stat(filepath.Join(dir, "manifest.nix")) |
| 455 | if errors.Is(err, fs.ErrNotExist) { |
| 456 | return nil |
| 457 | } |
| 458 | if err != nil { |
| 459 | return errors.WithStack(err) |
| 460 | } |
| 461 | |
| 462 | return errors.WithStack(os.Remove(profileDir)) |
| 463 | } |
| 464 | |
| 465 | func (d *Devbox) installPackages(ctx context.Context, mode installMode) error { |
| 466 | defer debug.FunctionTimer().End() |
no test coverage detected