diff --git a/pkgs/applications/networking/protonmail-bridge/common.nix b/pkgs/applications/networking/protonmail-bridge/common.nix new file mode 100644 index 0000000..e10641a --- /dev/null +++ b/pkgs/applications/networking/protonmail-bridge/common.nix @@ -0,0 +1,54 @@ +{ lib +, fetchFromGitHub +, buildGoModule +, pkg-config +, libsecret +}: + +{ pname +, tags +, ... +}@args: + +buildGoModule (lib.recursiveUpdate args rec { + inherit pname; + version = "1.5.6"; + + src = fetchFromGitHub { + owner = "ProtonMail"; + repo = "proton-bridge"; + rev = "br-${version}"; + sha256 = "1na8min9cmn82lpad58abw6837k303fr09l6cvzswaxs73f231ig"; + }; + + vendorSha256 = "1219xa1347877bfhnid15y6w9s4hf1czbrmll2iha4gpsmg066bb"; + + nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ + pkg-config + ]; + + buildInputs = (args.buildInputs or [ ]) ++ [ + libsecret + ]; + + buildFlagsArray = + let + t = "github.com/ProtonMail/proton-bridge/pkg/constants"; + in + [ + "-tags=${tags}" + '' + -ldflags= + -X ${t}.Version=${version} + -X ${t}.Revision=unknown + -X ${t}.BuildDate=unknown + '' + ]; + + meta = with lib; { + description = "Integrate ProtonMail paid account with any program that supports IMAP and SMTP"; + homepage = "https://protonmail.com"; + license = licenses.gpl3; + plaforms = platforms.x86_64; + }; +}) diff --git a/pkgs/applications/networking/protonmail-bridge/default.nix b/pkgs/applications/networking/protonmail-bridge/default.nix index 375a5df..9bbd9cc 100644 --- a/pkgs/applications/networking/protonmail-bridge/default.nix +++ b/pkgs/applications/networking/protonmail-bridge/default.nix @@ -10,60 +10,11 @@ , qtbase , qtdoc }: - let - - builder = - { pname - , tags - , ... - }@args: - - buildGoModule (lib.recursiveUpdate args rec { - inherit pname; - version = "1.5.6"; - - src = fetchFromGitHub { - owner = "ProtonMail"; - repo = "proton-bridge"; - rev = "br-${version}"; - sha256 = "1na8min9cmn82lpad58abw6837k303fr09l6cvzswaxs73f231ig"; - }; - - vendorSha256 = "1219xa1347877bfhnid15y6w9s4hf1czbrmll2iha4gpsmg066bb"; - - nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ - pkg-config - ]; - - buildInputs = (args.buildInputs or [ ]) ++ [ - libsecret - ]; - - buildFlagsArray = - let - t = "github.com/ProtonMail/proton-bridge/pkg/constants"; - in - [ - "-tags=${tags}" - '' - -ldflags= - -X ${t}.Version=${version} - -X ${t}.Revision=unknown - -X ${t}.BuildDate=unknown - '' - ]; - - meta = with lib; { - description = "Integrate ProtonMail paid account with any program that supports IMAP and SMTP"; - homepage = "https://protonmail.com"; - license = licenses.gpl3; - plaforms = platforms.x86_64; - }; - }); - + builder = import ./common.nix { + inherit lib fetchFromGitHub buildGoModule libsecret pkg-config; + }; in - { protonmail-bridge = builder (import ./app.nix { inherit qtbase go goModules; }); protonmail-bridge-headless = builder (import ./headless.nix { });