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

Function Build

internal/nix/build.go:21–51  ·  view source on GitHub ↗
(ctx context.Context, args *BuildArgs, installables ...string)

Source from the content-addressed store, hash-verified

19}
20
21func Build(ctx context.Context, args *BuildArgs, installables ...string) error {
22 defer debug.FunctionTimer().End()
23
24 FixInstallableArgs(installables)
25
26 // --impure is required for allowUnfreeEnv/allowInsecureEnv to work.
27 cmd := Command("build", "--impure")
28 cmd.Args = appendArgs(cmd.Args, args.Flags)
29 cmd.Args = appendArgs(cmd.Args, installables)
30 // Adding extra substituters only here to be conservative, but this could also
31 // be added to ExperimentalFlags() in the future.
32 if len(args.ExtraSubstituters) > 0 {
33 cmd.Args = append(cmd.Args,
34 "--extra-substituters",
35 strings.Join(args.ExtraSubstituters, " "),
36 )
37 }
38 cmd.Env = append(allowUnfreeEnv(os.Environ()), args.Env...)
39 if args.AllowInsecure {
40 slog.Debug("Setting Allow-insecure env-var\n")
41 cmd.Env = allowInsecureEnv(cmd.Env)
42 }
43
44 // If nix build runs as tty, the output is much nicer. If we ever
45 // need to change this to our own writers, consider that you may need
46 // to implement your own nicer output. --print-build-logs flag may be useful.
47 cmd.Stdin = os.Stdin
48 cmd.Stdout = args.Writer
49 cmd.Stderr = args.Writer
50 return cmd.Run(ctx)
51}

Callers 1

Calls 8

FunctionTimerFunction · 0.92
FixInstallableArgsFunction · 0.85
appendArgsFunction · 0.85
allowUnfreeEnvFunction · 0.85
allowInsecureEnvFunction · 0.85
EndMethod · 0.80
CommandFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected