about summary refs log tree commit diff
path: root/pkgs/tools/security/vaultwarden/update.nix
blob: 0fc4b45a1296cb897a8bc740ab581cbfc09e6a62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{ writeShellScript
, lib
, nix-update
, curl
, git
, gnugrep
, gnused
, jq
}:

writeShellScript "update-vaultwarden" ''
  PATH=${lib.makeBinPath [ curl git gnugrep gnused jq nix-update ]}

  set -euxo pipefail

  VAULTWARDEN_VERSION=$(curl --silent https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest | jq -r '.tag_name')
  nix-update "vaultwarden" --version "$VAULTWARDEN_VERSION"

  URL="https://raw.githubusercontent.com/dani-garcia/vaultwarden/''${VAULTWARDEN_VERSION}/docker/Dockerfile.j2"
  WEBVAULT_VERSION=$(curl --silent "$URL" | grep "set vault_version" | sed -E "s/.*\"([^\"]+)\".*/\\1/")
  nix-update "vaultwarden.webvault" --version "$WEBVAULT_VERSION"
''