diff --git a/pkgs/tools/security/ripasso/build-on-macos.patch b/pkgs/tools/security/ripasso/build-on-macos.patch new file mode 100644 index 000000000000..0c9aa02b9dff --- /dev/null +++ b/pkgs/tools/security/ripasso/build-on-macos.patch @@ -0,0 +1,55 @@ +diff --git a/cursive/Cargo.toml b/cursive/Cargo.toml +index 8cc0c1e..815c170 100644 +--- a/cursive/Cargo.toml ++++ b/cursive/Cargo.toml +@@ -20,8 +20,9 @@ gettext = "0.4.0" + lazy_static = "1.4.0" + toml = "0.5.9" + term_size = "0.3.2" +-wl-clipboard-rs = "0.7.0" + hex = "0.4.3" ++[target.'cfg(target_os = "linux")'.dependencies] ++wl-clipboard-rs = "0.7.0" + + [dependencies.config] + version = "0.11.0" +diff --git a/cursive/src/helpers.rs b/cursive/src/helpers.rs +index 7c2f733..9d63760 100644 +--- a/cursive/src/helpers.rs ++++ b/cursive/src/helpers.rs +@@ -23,6 +23,7 @@ use cursive::{ + }; + use pass::Result; + use ripasso::{crypto::CryptoImpl, pass}; ++#[cfg(target_os = "linux")] + use wl_clipboard_rs::copy::{MimeType, Options, Source}; + + /// Displays an error in a cursive dialog +@@ -48,7 +49,8 @@ pub fn errorbox(ui: &mut Cursive, err: &pass::Error) { + + /// Copies content to the clipboard. + /// It first tries to copy to a wayland clipboard, and if that's not availible due to that the +-/// user runs x11/mac/windows we instead try the more generic clipboard crate. ++/// user runs x11 we instead try the more generic clipboard crate. ++#[cfg(target_os = "linux")] + pub fn set_clipboard(content: String) -> Result<()> { + let opts = Options::new(); + let result = opts.copy( +@@ -62,6 +64,17 @@ pub fn set_clipboard(content: String) -> Result<()> { + Ok(()) + } + ++/// Copies content to the clipboard. ++/// It first tries to copy to a wayland clipboard, and if that's not availible due to that the ++/// user runs mac/windows we instead try the more generic clipboard crate. ++#[cfg(not(target_os = "linux"))] ++pub fn set_clipboard(content: String) -> Result<()> { ++ let mut ctx = clipboard::ClipboardContext::new()?; ++ ctx.set_contents(content)?; ++ ++ Ok(()) ++} ++ + pub fn get_value_from_input(s: &mut Cursive, input_name: &str) -> Option> { + let mut password = None; + s.call_on_name(input_name, |e: &mut EditView| { diff --git a/pkgs/tools/security/ripasso/cursive.nix b/pkgs/tools/security/ripasso/cursive.nix index 1a2ed1374611..22d5009deda9 100644 --- a/pkgs/tools/security/ripasso/cursive.nix +++ b/pkgs/tools/security/ripasso/cursive.nix @@ -1,26 +1,29 @@ -{ stdenv, lib, rustPlatform, fetchFromGitHub, pkg-config, ncurses, python3, openssl, libgpg-error, gpgme, xorg, AppKit, Security, installShellFiles }: +{ stdenv, lib, rustPlatform, fetchFromGitHub, pkg-config, python3, openssl, libgpg-error, gpgme, xorg, nettle, llvmPackages, clang, AppKit, Security, installShellFiles }: with rustPlatform; buildRustPackage rec { - version = "0.5.2"; + version = "0.6.2"; pname = "ripasso-cursive"; src = fetchFromGitHub { owner = "cortex"; repo = "ripasso"; rev = "release-${version}"; - sha256 = "sha256-De/xCDzdRHCslD0j6vT8bwjcMTf5R8KZ32aaB3i+Nig="; + sha256 = "sha256-OKFgBfm4d9IqSJFjg+J1XdsgQrfuIaoRIhVJQeZ+558="; }; - patches = [ ./fix-tests.patch ]; + patches = [ ./fix-tests.patch ./build-on-macos.patch ]; - cargoSha256 = "sha256-ZmHzxHV4uIxPlLkkOLJApPNLo0GGVj9EopoIwi/j6DE="; + # Needed so bindgen can find libclang.so + LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib"; + + cargoSha256 = "sha256-cAhLI5IES6FM3/rjHjokLq5pCoA08K/8lpdAeSNrTFs="; cargoBuildFlags = [ "-p ripasso-cursive" ]; - nativeBuildInputs = [ pkg-config gpgme python3 installShellFiles ]; + nativeBuildInputs = [ pkg-config gpgme python3 installShellFiles clang ]; buildInputs = [ - ncurses openssl libgpg-error gpgme xorg.libxcb + openssl libgpg-error gpgme xorg.libxcb nettle ] ++ lib.optionals stdenv.isDarwin [ AppKit Security ]; preCheck = '' diff --git a/pkgs/tools/security/ripasso/fix-tests.patch b/pkgs/tools/security/ripasso/fix-tests.patch index 85b1714e5c29..dbb4b2dfd318 100644 --- a/pkgs/tools/security/ripasso/fix-tests.patch +++ b/pkgs/tools/security/ripasso/fix-tests.patch @@ -1,82 +1,12 @@ ---- a/src/pass/test.rs -+++ a/src/pass/test.rs -@@ -83,6 +83,7 @@ +diff --git a/src/tests/test_helpers.rs b/src/tests/test_helpers.rs +index 73e4175..d2ed70b 100644 +--- a/src/tests/test_helpers.rs ++++ b/src/tests/test_helpers.rs +@@ -53,6 +53,7 @@ fn get_testres_path() -> PathBuf { base_path.pop(); base_path.pop(); base_path.pop(); + base_path.pop(); base_path.push("testres"); - let home: PathBuf = base_path.clone(); -@@ -114,6 +115,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.push("testres"); - - let home: PathBuf = base_path.clone(); -@@ -144,6 +146,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.push("testres"); - - let home: PathBuf = base_path.clone(); -@@ -185,6 +188,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.push("testres"); - - let home: PathBuf = base_path.clone(); -@@ -220,6 +224,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.push("testres"); - - let home: PathBuf = base_path.clone(); -@@ -267,6 +272,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.push("testres"); - - let home: PathBuf = base_path.clone(); -@@ -298,6 +304,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.push("testres"); - - let home: PathBuf = base_path.clone(); -@@ -337,6 +344,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.push("testres"); - - let home: PathBuf = base_path.clone(); -@@ -828,6 +836,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.push("testres"); - - let home: PathBuf = base_path.clone(); -@@ -860,6 +869,7 @@ - base_path.pop(); - base_path.pop(); - base_path.pop(); -+ base_path.pop(); - base_path.pop(); - base_path.push("testres"); - + base_path