()
| 17 | const currentGlobalProfile = "default" |
| 18 | |
| 19 | func GlobalDataPath() (string, error) { |
| 20 | path := xdg.DataSubpath(filepath.Join("devbox/global", currentGlobalProfile)) |
| 21 | if err := os.MkdirAll(path, 0o755); err != nil { |
| 22 | return "", errors.WithStack(err) |
| 23 | } |
| 24 | |
| 25 | nixProfilePath := filepath.Join(path) |
| 26 | currentPath := xdg.DataSubpath("devbox/global/current") |
| 27 | |
| 28 | // For now default is always current. In the future we will support multiple |
| 29 | // and allow user to switch. Remove any existing symlink and create a new one |
| 30 | // because previous versions of devbox may have created a symlink to a |
| 31 | // different profile. |
| 32 | existing, _ := os.Readlink(currentPath) |
| 33 | if existing != nixProfilePath { |
| 34 | _ = os.Remove(currentPath) |
| 35 | } |
| 36 | |
| 37 | err := os.Symlink(nixProfilePath, currentPath) |
| 38 | if err != nil && !errors.Is(err, fs.ErrExist) { |
| 39 | return "", errors.WithStack(err) |
| 40 | } |
| 41 | |
| 42 | return path, nil |
| 43 | } |
no test coverage detected