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

Method NeedsRun

internal/devbox/providers/nixcache/setup.go:77–104  ·  view source on GitHub ↗
(ctx context.Context, lastRun setup.RunInfo)

Source from the content-addressed store, hash-verified

75}
76
77func (s *setupTask) NeedsRun(ctx context.Context, lastRun setup.RunInfo) bool {
78 if _, err := nix.DaemonVersion(ctx); err != nil {
79 // This looks like a single-user install, so no need to
80 // configure the daemon or root's AWS credentials.
81 slog.Error("nixcache: skipping setup: error connecting to nix daemon, assuming single-user install", "err", err)
82 return false
83 }
84
85 if lastRun.Time.IsZero() {
86 slog.Debug("nixcache: running setup: first time setup")
87 return true
88 }
89 cfg, err := nix.CurrentConfig(ctx)
90 if err != nil {
91 slog.Error("nixcache: running setup: error getting current nix config, assuming user isn't trusted", "user", s.username)
92 return true
93 }
94 trusted, err := cfg.IsUserTrusted(ctx, s.username)
95 if err != nil {
96 slog.Error("nixcache: running setup: error checking if user is trusted, assuming they aren't", "user", s.username)
97 return true
98 }
99 if !trusted {
100 slog.Debug("nixcache: running setup: user isn't trusted", "user", s.username)
101 return true
102 }
103 return false
104}
105
106func (s *setupTask) Run(ctx context.Context) error {
107 ran, err := setup.SudoDevbox(ctx, "cache", "configure", "--user", s.username)

Callers

nothing calls this directly

Calls 4

DaemonVersionFunction · 0.92
CurrentConfigFunction · 0.92
IsUserTrustedMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected