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

Function CurrentConfig

internal/nix/config.go:38–55  ·  view source on GitHub ↗

CurrentConfig reads the current Nix configuration.

(ctx context.Context)

Source from the content-addressed store, hash-verified

36
37// CurrentConfig reads the current Nix configuration.
38func CurrentConfig(ctx context.Context) (Config, error) {
39 // `nix show-config` is deprecated in favor of `nix config show`, but we
40 // want to remain compatible with older Nix versions.
41 cmd := Command("show-config", "--json")
42 out, err := cmd.Output(ctx)
43 var exitErr *exec.ExitError
44 if errors.As(err, &exitErr) && len(exitErr.Stderr) != 0 {
45 return Config{}, redact.Errorf("command %s: %v: %s", redact.Safe(cmd), err, exitErr.Stderr)
46 }
47 if err != nil {
48 return Config{}, redact.Errorf("command %s: %v", cmd, err)
49 }
50 cfg := Config{}
51 if err := json.Unmarshal(out, &cfg); err != nil {
52 return Config{}, redact.Errorf("unmarshal JSON output from %s: %v", redact.Safe(cmd), err)
53 }
54 return cfg, nil
55}
56
57// IsUserTrusted reports if the current OS user is in the trusted-users list. If
58// there are any groups in the list, it also checks if the user belongs to any

Callers 3

NeedsRunMethod · 0.92
RunMethod · 0.92
TestConfigIsUserTrustedFunction · 0.85

Calls 4

ErrorfFunction · 0.92
SafeFunction · 0.92
CommandFunction · 0.70
OutputMethod · 0.45

Tested by 1

TestConfigIsUserTrustedFunction · 0.68