aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/turso-cli.nix
blob: 2eef83548a17467fa22efaf487d6ef4b26e5bbf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# The turso.tech cloud CLI. Not in nixpkgs — nixpkgs' `turso` is the database
# engine (the `tursodb` shell). Upstream ships it via a Homebrew tap whose
# `sqld` dependency tap is broken, so this unpacks the same GoReleaser tarball.
{
  lib,
  stdenvNoCC,
  fetchurl,
  installShellFiles,
}:

let
  version = "1.0.32";

  sources = {
    aarch64-darwin = {
      suffix = "Darwin_arm64";
      hash = "sha256-nwIrfTOYZJZfPCDQk8cZEKTk7tidvEr/paSSLizSRUQ=";
    };
    x86_64-darwin = {
      suffix = "Darwin_x86_64";
      hash = "sha256-9Mk0ZKFR9QQ/gE5SDoD4PDF/t7kQZWnLk39eaKpMiHw=";
    };
    aarch64-linux = {
      suffix = "Linux_arm64";
      hash = "sha256-kmipCZ4lTlyHMIKL8FDVf9/2Zhg8i/SeJuhuy5CrMXI=";
    };
    x86_64-linux = {
      suffix = "Linux_x86_64";
      hash = "sha256-MU1Ocqez2Ltv2yEiyfz0I6AKVsVm4UDeAognbG7UNbI=";
    };
  };

  source =
    sources.${stdenvNoCC.hostPlatform.system}
      or (throw "turso-cli: unsupported platform ${stdenvNoCC.hostPlatform.system}");
in
stdenvNoCC.mkDerivation {
  pname = "turso-cli";
  inherit version;

  src = fetchurl {
    url = "https://github.com/tursodatabase/homebrew-tap/releases/download/v${version}/homebrew-tap_${source.suffix}.tar.gz";
    inherit (source) hash;
  };

  sourceRoot = ".";

  nativeBuildInputs = [ installShellFiles ];

  installPhase = ''
    runHook preInstall
    install -Dm755 turso $out/bin/turso
    installShellCompletion \
      --bash completions/turso.bash \
      --zsh completions/turso.zsh \
      --fish completions/turso.fish
    runHook postInstall
  '';

  meta = {
    description = "CLI for managing Turso databases in the cloud";
    homepage = "https://github.com/tursodatabase/turso-cli";
    license = lib.licenses.mit;
    mainProgram = "turso";
    platforms = lib.attrNames sources;
    sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
  };
}