MCPcopy Index your code
hub / github.com/jetify-com/devbox / GenerateForPrintEnv

Function GenerateForPrintEnv

internal/shellgen/generate.go:29–65  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

27// devbox.PrintEnv, which is the core function from which devbox shell/run/direnv
28// functionality is derived.
29func 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.
68var (

Callers 2

recomputeStateMethod · 0.92
GenerateMethod · 0.92

Calls 14

ErrorfFunction · 0.92
newFlakePlanFunction · 0.85
genPathFunction · 0.85
writeFromTemplateFunction · 0.85
newGlibcPatchFlakeFunction · 0.85
FlakePathFunction · 0.85
makeFlakeFileFunction · 0.85
WriteScriptsToFilesFunction · 0.85
EndMethod · 0.80
writeToMethod · 0.80
ProjectDirMethod · 0.65
StdenvMethod · 0.65

Tested by

no test coverage detected