diff --git a/README.md b/README.md index 5b13d5e..b584920 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ curl -fsSL -H "Authorization: token $GITEA_TOKEN" \ On SteamOS, the one sudo prompt makes `/nix` owned by `deck`. Nix then runs in single-user mode, with no daemon and no units in `/etc`. -Then, once per machine: +Then, once per machine (`bw` already points at `https://vault.etvamerica.com`; override with `BW_SERVER=...`): ```bash bw login && export BW_SESSION=$(bw unlock --raw) diff --git a/bin/dot b/bin/dot index 4aa778c..571e493 100755 --- a/bin/dot +++ b/bin/dot @@ -213,9 +213,18 @@ cmd_boxes() { # ---------------------------------------------------------------- secrets (Bitwarden) BW_PREFIX="dotfiles" +BW_SERVER="${BW_SERVER:-https://vault.etvamerica.com}" + +# Point bw at the Vaultwarden instance (only possible while logged out). +bw_server() { + have bw || return 0 + [ "$(bw config server 2>/dev/null)" = "$BW_SERVER" ] && return 0 + [ "$(bw status | jq -r .status)" = unauthenticated ] && bw config server "$BW_SERVER" >/dev/null && ok "bw server → $BW_SERVER" +} bw_ready() { have bw || die "bitwarden-cli missing (dot switch)" + bw_server local status; status="$(bw status | jq -r .status)" case "$status" in unlocked) return 0 ;; @@ -407,6 +416,7 @@ cmd_bootstrap() { export PATH="$HOME/.nix-profile/bin:$HOME/.local/bin:$PATH" cmd_apps [ "$(profile)" = full ] && { cmd_wallpapers || true; } + bw_server || true cat <