nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 gitUpdater,
6 installShellFiles,
7 rustPlatform,
8}:
9
10rustPlatform.buildRustPackage rec {
11 pname = "jwt-cli";
12 version = "6.2.0";
13
14 src = fetchFromGitHub {
15 owner = "mike-engel";
16 repo = "jwt-cli";
17 tag = version;
18 hash = "sha256-2pYCNLopvIHcKiN4qewQCdkGWHYQ6vQVCaApxGsRG9E=";
19 };
20
21 cargoHash = "sha256-lp2I5+zvFM46TmejtNn/qgVlAaL+xL9slZHduccO/5Q=";
22
23 nativeBuildInputs = [ installShellFiles ];
24
25 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
26 installShellCompletion --cmd jwt \
27 --bash <($out/bin/jwt completion bash) \
28 --fish <($out/bin/jwt completion fish) \
29 --zsh <($out/bin/jwt completion zsh)
30 '';
31
32 doInstallCheck = true;
33
34 installCheckPhase = ''
35 $out/bin/jwt --version > /dev/null
36 $out/bin/jwt decode eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c \
37 | grep -q 'John Doe'
38 '';
39
40 passthru.updateScript = gitUpdater { };
41
42 meta = {
43 description = "Super fast CLI tool to decode and encode JWTs";
44 homepage = "https://github.com/mike-engel/jwt-cli";
45 changelog = "https://github.com/mike-engel/jwt-cli/releases/tag/${version}";
46 license = lib.licenses.mit;
47 maintainers = with lib.maintainers; [ rycee ];
48 mainProgram = "jwt";
49 };
50}