diff --git a/pkgs/applications/networking/instant-messengers/signalbackup-tools/apple-sdk-missing-utimensat.patch b/pkgs/applications/networking/instant-messengers/signalbackup-tools/apple-sdk-missing-utimensat.patch new file mode 100644 index 000000000000..61474d0ab4fc --- /dev/null +++ b/pkgs/applications/networking/instant-messengers/signalbackup-tools/apple-sdk-missing-utimensat.patch @@ -0,0 +1,34 @@ +diff --git a/signalbackup/setfiletimestamp.cc b/signalbackup/setfiletimestamp.cc +index f53a168..d2d1c5e 100644 +--- a/signalbackup/setfiletimestamp.cc ++++ b/signalbackup/setfiletimestamp.cc +@@ -21,24 +21,23 @@ + + #if !defined(_WIN32) && !defined(__MINGW64__) + +-#include +-#include ++#include + + bool SignalBackup::setFileTimeStamp(std::string const &file, long long int time_usec) const + { +- struct timespec ntimes[] = ++ struct timeval ntimes[] = + { + { // ntimes[0] = + time_usec / 1000, // tv_sec, seconds +- (time_usec % 1000) * 1000 // tv_usec, nanoseconds ++ static_cast(time_usec) // tv_usec, nanoseconds + }, + { // ntimes[1] = + time_usec / 1000, // tv_sec, seconds +- (time_usec % 1000) * 1000 // tv_usec, nanoseconds ++ static_cast(time_usec) // tv_usec, nanoseconds + } + }; + +- return (utimensat(AT_FDCWD, file.c_str(), ntimes, 0) == 0); ++ return (utimes(file.c_str(), ntimes) == 0); + } + + #else // this is poorly tested, I don't have windows diff --git a/pkgs/applications/networking/instant-messengers/signalbackup-tools/default.nix b/pkgs/applications/networking/instant-messengers/signalbackup-tools/default.nix new file mode 100644 index 000000000000..5da0536b3794 --- /dev/null +++ b/pkgs/applications/networking/instant-messengers/signalbackup-tools/default.nix @@ -0,0 +1,45 @@ +{ lib, stdenv, fetchFromGitHub, openssl, sqlite }: + +stdenv.mkDerivation rec { + pname = "signalbackup-tools"; + version = "20220107"; + + src = fetchFromGitHub { + owner = "bepaald"; + repo = pname; + rev = version; + sha256 = "sha256-sB8/xQgSORtwupcwSejKUhHoz04exdYS0ymefw9wXDQ="; + }; + + # Remove when Apple SDK is >= 10.13 + patches = lib.optional (stdenv.system == "x86_64-darwin") ./apple-sdk-missing-utimensat.patch; + + buildInputs = [ openssl sqlite ]; + buildFlags = [ + "-Wall" + "-Wextra" + "-Wshadow" + "-Wold-style-cast" + "-Woverloaded-virtual" + "-pedantic" + "-std=c++2a" + "-O3" + "-march=native" + ]; + buildPhase = '' + $CXX $buildFlags */*.cc *.cc -lcrypto -lsqlite3 -o signalbackup-tools + ''; + + installPhase = '' + mkdir -p $out/bin + cp signalbackup-tools $out/bin/ + ''; + + meta = with lib; { + description = "Tool to work with Signal Backup files"; + homepage = "https://github.com/bepaald/signalbackup-tools"; + license = licenses.gpl3Only; + maintainers = [ maintainers.malo ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 203a6e9ea12d..efb6f2ab5bb1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9594,6 +9594,8 @@ with pkgs; sigil = libsForQt5.callPackage ../applications/editors/sigil { }; + signalbackup-tools = callPackage ../applications/networking/instant-messengers/signalbackup-tools { }; + signald = callPackage ../applications/networking/instant-messengers/signald { }; signal-cli = callPackage ../applications/networking/instant-messengers/signal-cli { };