Commit 653e884
authored
nixcache: configure auth with
Add a hidden `devbox cache configure` command that sets up Nix so it can
authenticate with a private Devbox cache. This is a first step.
Ultimately, we'd like to do this configuration automatically before
building. We just need to make sure we don't re-prompt the user for sudo
or slow down commands like `devbox run` or `devbox shell`.
Configuring auth goes as follows:
1. Check to see if the Nix daemon is running. If it isn't, we don't need
to do anything.
2. Otherwise, we check to see if `~root/.aws/config` exists. If it does,
we assume that we've already configured the root user's AWS credentials.
This won't handle situations where the user already has a root AWS
config and can be improved.
3. If the AWS config doesn't exist, prompt the user to escalate to root.
If they say yes, relaunch `devbox cache configure`.
4. The new devbox process running as root writes an AWS config file that
tells the AWS CLI/SDKs to authenticate by running `devbox cache
credentials`.
Note that we need to use the default AWS profile. There's a bug in Nix
where non-default profiles (specified in the S3 URI with
?profile=devbox) don't use the default credential chain. If this gets
fixed, we should use a separate profile so that we don't interfere with
any AWS options set by the user (although hopefully this is rare for
root).devbox cache configure (#1961)1 parent ef831bb commit 653e884
File tree
6 files changed
+276
-106
lines changed- internal
- boxcli
- devbox
- providers/nixcache
6 files changed
+276
-106
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | | - | |
| 42 | + | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | 65 | | |
68 | 66 | | |
69 | 67 | | |
| |||
365 | 363 | | |
366 | 364 | | |
367 | 365 | | |
368 | | - | |
369 | | - | |
| 366 | + | |
| 367 | + | |
370 | 368 | | |
371 | 369 | | |
372 | 370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
38 | | - | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
70 | 91 | | |
71 | 92 | | |
72 | 93 | | |
73 | 94 | | |
74 | 95 | | |
75 | 96 | | |
76 | 97 | | |
77 | | - | |
| 98 | + | |
78 | 99 | | |
79 | 100 | | |
80 | 101 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | 102 | | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
97 | | - | |
98 | | - | |
| 106 | + | |
| 107 | + | |
99 | 108 | | |
100 | 109 | | |
101 | 110 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
45 | 57 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 58 | + | |
49 | 59 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | | - | |
449 | | - | |
450 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
451 | 452 | | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
460 | 458 | | |
| 459 | + | |
| 460 | + | |
461 | 461 | | |
462 | 462 | | |
463 | 463 | | |
| |||
0 commit comments