| 91 | } |
| 92 | |
| 93 | func newGlibcPatchFlake(nixpkgs flake.Ref, packages []*devpkg.Package) (glibcPatchFlake, error) { |
| 94 | patchFlake := glibcPatchFlake{ |
| 95 | DevboxFlake: flake.Ref{ |
| 96 | Type: flake.TypeGitHub, |
| 97 | Owner: "jetify-com", |
| 98 | Repo: "devbox", |
| 99 | Ref: build.Version, |
| 100 | }, |
| 101 | NixpkgsGlibcFlakeRef: nixpkgs.String(), |
| 102 | } |
| 103 | |
| 104 | // In dev builds, use the local Devbox flake for patching packages |
| 105 | // instead of the one on GitHub. Using build.IsDev doesn't work because |
| 106 | // DEVBOX_PROD=1 will attempt to download 0.0.0-dev from GitHub. |
| 107 | if strings.HasPrefix(build.Version, "0.0.0") { |
| 108 | src, err := build.SourceDir() |
| 109 | if err != nil { |
| 110 | slog.Error("can't find the local devbox flake for patching, falling back to the latest github release", "err", err) |
| 111 | patchFlake.DevboxFlake = flake.Ref{ |
| 112 | Type: flake.TypeGitHub, |
| 113 | Owner: "jetify-com", |
| 114 | Repo: "devbox", |
| 115 | } |
| 116 | } else { |
| 117 | patchFlake.DevboxFlake = flake.Ref{Type: flake.TypePath, Path: src} |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | for _, pkg := range packages { |
| 122 | // Check to see if this is a CUDA package. If so, we need to add |
| 123 | // it to the flake dependencies so that we can patch other |
| 124 | // packages to reference it (like Python). |
| 125 | relAttrPath, err := patchFlake.systemRelativeAttrPath(pkg) |
| 126 | if err != nil { |
| 127 | return glibcPatchFlake{}, err |
| 128 | } |
| 129 | if strings.HasPrefix(relAttrPath, "cudaPackages") { |
| 130 | if err := patchFlake.addDependency(pkg); err != nil { |
| 131 | return glibcPatchFlake{}, err |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | if !pkg.Patch { |
| 136 | continue |
| 137 | } |
| 138 | if err := patchFlake.addOutput(pkg); err != nil { |
| 139 | return glibcPatchFlake{}, err |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | slog.Debug("creating new patch flake", "flake", &patchFlake) |
| 144 | return patchFlake, nil |
| 145 | } |
| 146 | |
| 147 | // addInput adds a flake input that provides pkg. |
| 148 | func (g *glibcPatchFlake) addInput(pkg *devpkg.Package) error { |