GenerateForPrintEnv will create all the files necessary for processing devbox.PrintEnv, which is the core function from which devbox shell/run/direnv functionality is derived.
(ctx context.Context, devbox devboxer)
| 27 | // devbox.PrintEnv, which is the core function from which devbox shell/run/direnv |
| 28 | // functionality is derived. |
| 29 | func GenerateForPrintEnv(ctx context.Context, devbox devboxer) error { |
| 30 | defer trace.StartRegion(ctx, "GenerateForPrintEnv").End() |
| 31 | |
| 32 | plan, err := newFlakePlan(ctx, devbox) |
| 33 | if err != nil { |
| 34 | return err |
| 35 | } |
| 36 | |
| 37 | outPath := genPath(devbox) |
| 38 | |
| 39 | // Preserving shell.nix to avoid breaking old-style .envrc users |
| 40 | _, err = writeFromTemplate(outPath, plan, "shell.nix", "shell.nix") |
| 41 | if err != nil { |
| 42 | return errors.WithStack(err) |
| 43 | } |
| 44 | |
| 45 | // Gitignore file is added to the .devbox directory |
| 46 | _, err = writeFromTemplate(filepath.Join(devbox.ProjectDir(), ".devbox"), plan, ".gitignore", ".gitignore") |
| 47 | if err != nil { |
| 48 | return errors.WithStack(err) |
| 49 | } |
| 50 | |
| 51 | if plan.needsGlibcPatch() { |
| 52 | patch, err := newGlibcPatchFlake(devbox.Lockfile().Stdenv(), plan.Packages) |
| 53 | if err != nil { |
| 54 | return redact.Errorf("generate glibc patch flake: %v", err) |
| 55 | } |
| 56 | if err := patch.writeTo(filepath.Join(FlakePath(devbox), "glibc-patch")); err != nil { |
| 57 | return redact.Errorf("write glibc patch flake to directory: %v", err) |
| 58 | } |
| 59 | } |
| 60 | if err := makeFlakeFile(devbox, plan); err != nil { |
| 61 | return err |
| 62 | } |
| 63 | |
| 64 | return WriteScriptsToFiles(devbox) |
| 65 | } |
| 66 | |
| 67 | // Cache and buffers for generating templated files. |
| 68 | var ( |
no test coverage detected