nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 fetchFromGitHub,
3 installShellFiles,
4 lib,
5 libnitrokey,
6 rustPlatform,
7 stdenv,
8}:
9let
10 version = "0.4.1";
11in
12rustPlatform.buildRustPackage {
13 pname = "nitrocli";
14 inherit version;
15
16 src = fetchFromGitHub {
17 owner = "d-e-s-o";
18 repo = "nitrocli";
19 tag = "v${version}";
20 hash = "sha256-j1gvh/CmRhPTeesMIK5FtaqUW7c8hN3ub+kQ2NM3dNM=";
21 };
22
23 cargoHash = "sha256-lWFleq9uxoshPMx2mYULCyEar72ZjGfgf0HlRoYfG/M=";
24
25 # tests require a connected Nitrokey device
26 doCheck = false;
27
28 # link against packaged libnitrokey
29 USE_SYSTEM_LIBNITROKEY = 1;
30
31 nativeBuildInputs = [ installShellFiles ];
32
33 buildInputs = [ libnitrokey ];
34
35 postInstall =
36 (lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
37 installShellCompletion --cmd nitrocli \
38 --bash <($out/bin/shell-complete bash nitrocli) \
39 --fish <($out/bin/shell-complete fish nitrocli) \
40 --zsh <($out/bin/shell-complete zsh nitrocli)
41 '')
42 + ''
43 installManPage doc/nitrocli.1
44 rm $out/bin/shell-complete
45 '';
46
47 meta = {
48 description = "Command line tool for interacting with Nitrokey devices";
49 homepage = "https://github.com/d-e-s-o/nitrocli";
50 license = lib.licenses.gpl3Plus;
51 mainProgram = "nitrocli";
52 maintainers = with lib.maintainers; [ robinkrahl ];
53 };
54}