@@ -38,22 +38,28 @@ func Configure(ctx context.Context) error {
38
38
if err != nil {
39
39
return redact .Errorf ("nixcache: lookup current user: %v" , err )
40
40
}
41
- return configure (ctx , u .Username , false )
42
- }
43
41
44
- func ConfigureReprompt (ctx context.Context , username string ) error {
45
- return configure (ctx , username , true )
46
- }
42
+ task := & setupTask {u .Username }
47
43
48
- func configure (ctx context.Context , username string , reprompt bool ) error {
49
- if reprompt {
50
- setup .Reset (setupKey )
44
+ // This function might be called from other Devbox commands
45
+ // (such as devbox add), so we need to provide some context in the sudo
46
+ // prompt.
47
+ const sudoPrompt = "You're logged into a Devbox account, but Nix isn't setup to use your account's caches. " +
48
+ "Allow sudo to configure Nix?"
49
+ err = setup .ConfirmRun (ctx , setupKey , task , sudoPrompt )
50
+ if err != nil {
51
+ return redact .Errorf ("nixcache: run setup: %w" , err )
51
52
}
53
+ return nil
54
+ }
52
55
56
+ func ConfigureReprompt (ctx context.Context , username string ) error {
57
+ setup .Reset (setupKey )
53
58
task := & setupTask {username }
54
- const sudoPrompt = "You're logged into a Devbox account that now has access to a Nix cache. " +
55
- "Allow Devbox to configure Nix to use the new cache (requires sudo)?"
56
- err := setup .ConfirmRun (ctx , setupKey , task , sudoPrompt )
59
+
60
+ // We're reprompting, so the user explicitly asked to configure the
61
+ // cache. We can keep the sudo prompt short.
62
+ err := setup .ConfirmRun (ctx , setupKey , task , "Allow sudo to configure Nix?" )
57
63
if err != nil {
58
64
return redact .Errorf ("nixcache: run setup: %w" , err )
59
65
}
0 commit comments