Skip to content

Conversation

gcurtis
Copy link
Collaborator

@gcurtis gcurtis commented Apr 18, 2024

Fix a few issues with the current auto-configuration flow for private nix caches:

  • Track whether or not we've configured ~root/.aws/config in a separate state file in the user's home directory. This lets Devbox know if AWS has already been configured, even if it cannot read root's home directory.
  • If the user answers no to the sudo confirmation prompt, don't ask them again. This is so we don't pester the user every time they install a package.
  • Preserve XDG_STATE_HOME in sudo so that we write state files to the correct directory.
  • Append a timestamp to the ~root/.aws directory when we back it up. This allows multiple backups if the setup process is run more than once.

The logic for saving state around whether or not the cache setup has already run lives in a new setup package. The setup package tracks when a task last ran, what version of Devbox it ran with, and if there was an error. This makes it easier to define tasks that only run once for a user or only occur after an upgrade.

Fixes a few issues with the current auto-configuration flow for private
nix caches:

- Track whether or not we've configured ~root/.aws/config in a separate
  state file in the user's home directory. This lets Devbox know if AWS
  has already been configured, even if it cannot read root's home
  directory.
- If the user answers no to the sudo confirmation prompt, don't ask them
  again. This is so we don't pester the user every time they install a
  package.
- Preserve XDG_STATE_HOME in sudo so that we write state files to the
  correct directory.
- Append a timestamp to the ~root/.aws directory when we back it up.
  This allows multiple backups if the setup process is run more than
  once.

The logic for saving state around whether or not the cache setup has
already run lives in a new `setup` package. The `setup` package tracks
when a task last ran, what version of Devbox it ran with, and if there
was an error. This makes it easier to define tasks that only run once
for a user or only occur after an upgrade.
@gcurtis gcurtis requested review from mikeland73 and savil April 18, 2024 19:46
Copy link
Contributor

@mikeland73 mikeland73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving because it's not a regression, but my main comment is about not needing sudo for single user setups. I assume that if there's no daemon, nix build can be passed environment variables directly in which case we don't need either setup.

@gcurtis gcurtis merged commit 7a67909 into main Apr 19, 2024
@gcurtis gcurtis deleted the gcurtis/sudo-prompt branch April 19, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants