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

Function IncludeDevboxConfig

internal/nix/config.go:109–126  ·  view source on GitHub ↗
(ctx context.Context, username string)

Source from the content-addressed store, hash-verified

107}
108
109func IncludeDevboxConfig(ctx context.Context, username string) error {
110 info, _ := nix.Default.Info()
111 path := cmp.Or(info.SystemConfig, "/etc/nix/nix.conf")
112 includePath := filepath.Join(filepath.Dir(path), "devbox-nix.conf")
113 b := fmt.Appendf(nil, "# This config was auto-generated by Devbox.\n\nextra-trusted-users = %s\n", username)
114 if err := os.WriteFile(includePath, b, 0o664); err != nil {
115 return redact.Errorf("write devbox nix.conf: %v", err)
116 }
117
118 appended, err := appendConfigInclude(path, includePath)
119 if err != nil {
120 return err
121 }
122 if appended {
123 return restartDaemon(ctx)
124 }
125 return nil
126}
127
128func appendConfigInclude(srcPath, includePath string) (appended bool, err error) {
129 nixConf, err := os.OpenFile(srcPath, os.O_RDWR, 0)

Callers 1

RunMethod · 0.92

Calls 4

ErrorfFunction · 0.92
appendConfigIncludeFunction · 0.85
restartDaemonFunction · 0.85
InfoMethod · 0.45

Tested by

no test coverage detected