diff --git a/pkgs/by-name/ni/nitrocli/package.nix b/pkgs/by-name/ni/nitrocli/package.nix new file mode 100644 index 000000000000..3d16e5744a56 --- /dev/null +++ b/pkgs/by-name/ni/nitrocli/package.nix @@ -0,0 +1,54 @@ +{ + fetchFromGitHub, + installShellFiles, + lib, + libnitrokey, + rustPlatform, + stdenv, +}: +let + version = "0.4.1"; +in +rustPlatform.buildRustPackage { + pname = "nitrocli"; + inherit version; + + src = fetchFromGitHub { + owner = "d-e-s-o"; + repo = "nitrocli"; + tag = "v${version}"; + hash = "sha256-j1gvh/CmRhPTeesMIK5FtaqUW7c8hN3ub+kQ2NM3dNM="; + }; + + cargoHash = "sha256-loCVYe4vdalo2AvoMo9th/V9xXulaq6HlPOw3idbqEw="; + + # tests require a connected Nitrokey device + doCheck = false; + + # link against packaged libnitrokey + USE_SYSTEM_LIBNITROKEY = 1; + + nativeBuildInputs = [ installShellFiles ]; + + buildInputs = [ libnitrokey ]; + + postInstall = + (lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + installShellCompletion --cmd nitrocli \ + --bash <($out/bin/shell-complete bash nitrocli) \ + --fish <($out/bin/shell-complete fish nitrocli) \ + --zsh <($out/bin/shell-complete zsh nitrocli) + '') + + '' + installManPage doc/nitrocli.1 + rm $out/bin/shell-complete + ''; + + meta = { + description = "Command line tool for interacting with Nitrokey devices"; + homepage = "https://github.com/d-e-s-o/nitrocli"; + license = lib.licenses.gpl3Plus; + mainProgram = "nitrocli"; + maintainers = with lib.maintainers; [ robinkrahl ]; + }; +}