{ stdenv, fetchFromGitHub, pkgconfig, openssl, nur, makeRustPlatform }:

let
  rust = nur.repos.mozilla.rustChannelOf {
    date = "2019-02-01";
    channel = "nightly";
  };

  rustPlatform = makeRustPlatform {
    rustc = rust.rust;
    inherit (rust) cargo;
  };
in rustPlatform.buildRustPackage rec {
  name = "${pname}-${version}";
  pname = "bitwarden_rs";
  version = "1.6.1";

  src = fetchFromGitHub {
    owner = "dani-garcia";
    repo = pname;
    rev = "1.6.1";
    sha256 = "14rajlk7a0g0a69km7br5lssgqiriv4dadila5sharxvl627gf7m";
  };

  patches = [ ./cargo-config-1.patch ];
  buildInputs = [ pkgconfig openssl ];

  # RUSTC_BOOTSTRAP=1;

  cargoSha256 = "1cygrl7pk1b8adw5nvdi8an8g4g6fm1jav0jdfiz5iflr9pql4kp";

  meta = with stdenv.lib; {
    description = "An unofficial lightweight implementation of the bitwarden-server using rust and sqlite";
    homepage = https://github.com/dani-garcia/bitwarden_rs;
    license = licenses.GPL3;
    maintainers = with maintainers; [ msteen ];
    platforms = platforms.all;
  };
}