From 304d3932f453b1d0d370e843a67dfed8ca982361 Mon Sep 17 00:00:00 2001 From: xeals Date: Thu, 15 Oct 2020 21:49:24 +1100 Subject: [PATCH] protonmail-bridge: split into multiple files --- default.nix | 11 +-- .../networking/protonmail-bridge/app.nix | 44 ++++++++++ .../networking/protonmail-bridge/default.nix | 84 ++----------------- .../networking/protonmail-bridge/headless.nix | 30 +++++++ 4 files changed, 88 insertions(+), 81 deletions(-) create mode 100644 pkgs/applications/networking/protonmail-bridge/app.nix create mode 100644 pkgs/applications/networking/protonmail-bridge/headless.nix diff --git a/default.nix b/default.nix index dd4a7d3..fa08059 100644 --- a/default.nix +++ b/default.nix @@ -40,7 +40,9 @@ rec { amdgpu-fan = pkgs.callPackage ./pkgs/tools/misc/amdgpu-fan { }; - go-qt = pkgs.libsForQt512.callPackage ./pkgs/development/go-modules/qt { }; + goModules = pkgs.recurseIntoAttrs rec { + qt = pkgs.libsForQt512.callPackage ./pkgs/development/go-modules/qt { }; + }; # A functional Jetbrains IDE-with-plugins package set. jetbrains = @@ -106,11 +108,10 @@ rec { # The one in Nixpkgs still extracts the pre-built Debian package instead # of building from source. protonmailBridgePackages = pkgs.libsForQt512.callPackage ./pkgs/applications/networking/protonmail-bridge { - inherit go-qt; + inherit goModules; }; - inherit (protonmailBridgePackages) - protonmail-bridge - protonmail-bridge-headless; + protonmail-bridge = protonmailBridgePackages.protonmail-bridge; + protonmail-bridge-headless = protonmailBridgePackages.protonmail-bridge-headless; radeon-profile-daemon = pkgs.libsForQt5.callPackage ./pkgs/tools/misc/radeon-profile-daemon { }; diff --git a/pkgs/applications/networking/protonmail-bridge/app.nix b/pkgs/applications/networking/protonmail-bridge/app.nix new file mode 100644 index 0000000..f9032f8 --- /dev/null +++ b/pkgs/applications/networking/protonmail-bridge/app.nix @@ -0,0 +1,44 @@ +{ qtbase, go, goModules }: + +{ + pname = "protonmail-bridge"; + + tags = "pmapi_prod"; + + QT_PKG_CONFIG = "true"; + QT_VERSION = qtbase.version; + + nativeBuildInputs = [ + goModules.qt + qtbase + ]; + + buildPhase = '' + cp cmd/Desktop-Bridge/main.go . + + ## Enable writable vendor + GOMODULE=gomodule + mv vendor $GOMODULE-vendor + mkdir vendor + readarray -t files < <(find $GOMODULE-vendor/ -type f | grep -v github.com/therecipe/qt | sed "s/$GOMODULE-//") + for f in "''${files[@]}"; do + mkdir -p $(dirname $f) + cp -s $PWD/$GOMODULE-$f $f + done + unset GOMODULE + + ## + mkdir -p vendor/github.com/therecipe + cp -r gomodule-vendor/github.com/therecipe/qt vendor/github.com/therecipe/qt + chmod -R a+w vendor/github.com/therecipe/qt + + # Add vendor to GOPATH because fuck + mkdir -p $GOPATH + ln -s $PWD/vendor $GOPATH/src + + qtsetup check + GOROOT=${go}/share/go qtdeploy "''${buildFlagsArray[@]}" build desktop + ''; + + meta.broken = true; +} diff --git a/pkgs/applications/networking/protonmail-bridge/default.nix b/pkgs/applications/networking/protonmail-bridge/default.nix index 5086f3c..13a5d72 100644 --- a/pkgs/applications/networking/protonmail-bridge/default.nix +++ b/pkgs/applications/networking/protonmail-bridge/default.nix @@ -1,10 +1,9 @@ { stdenv -, lib , fetchFromGitHub , buildGoModule , go -, go-qt +, goModules , libsecret , pkg-config , qtbase @@ -13,12 +12,13 @@ let - common = + builder = { pname , tags , ... }@args: - buildGoModule (lib.recursiveUpdate args rec { + + buildGoModule (stdenv.lib.recursiveUpdate args rec { inherit pname; version = "1.3.2"; @@ -50,7 +50,7 @@ let '' ]; - meta = with lib; { + meta = with stdenv.lib; { description = "Integrate ProtonMail paid account with any program that supports IMAP and SMTP"; homepage = "https://protonmail.com"; license = licenses.gpl3; @@ -58,78 +58,10 @@ let }; }); + in { - protonmail-bridge = common { - pname = "protonmail-bridge"; - - tags = "pmapi_prod"; - - QT_PKG_CONFIG = "true"; - QT_VERSION = qtbase.version; - - nativeBuildInputs = [ - go-qt - qtbase - ]; - - buildPhase = '' - cp cmd/Desktop-Bridge/main.go . - - ## Enable writable vendor - GOMODULE=gomodule - mv vendor $GOMODULE-vendor - mkdir vendor - readarray -t files < <(find $GOMODULE-vendor/ -type f | grep -v github.com/therecipe/qt | sed "s/$GOMODULE-//") - for f in "''${files[@]}"; do - mkdir -p $(dirname $f) - cp -s $PWD/$GOMODULE-$f $f - done - unset GOMODULE - - ## - mkdir -p vendor/github.com/therecipe - cp -r gomodule-vendor/github.com/therecipe/qt vendor/github.com/therecipe/qt - chmod -R a+w vendor/github.com/therecipe/qt - - # Add vendor to GOPATH because fuck - mkdir -p $GOPATH - ln -s $PWD/vendor $GOPATH/src - - qtsetup check - GOROOT=${go}/share/go qtdeploy "''${buildFlagsArray[@]}" build desktop - ''; - - meta.broken = true; - }; - - protonmail-bridge-headless = common rec { - pname = "protonmail-bridge-headless"; - - tags = "pmapi_prod nogui"; - - # FIXME: There's something fucky going on in the buildFlagsArray - # substitution. I shouldn't need to do this. - buildPhase = - let - t = "github.com/ProtonMail/proton-bridge/pkg/constants"; - in - '' - runHook preBuild - - go install \ - -tags="${tags}" \ - -ldflags="-X ${t}.Version=1.3.2 -X ${t}.Revision=unknown -X ${t}.BuildDate=unknown" \ - cmd/Desktop-Bridge/main.go - mv $GOPATH/bin/main $GOPATH/bin/Desktop-Bridge - - runHook postBuild - ''; - - # Fix up name. - postInstall = '' - mv $out/bin/Desktop-Bridge $out/bin/protonmail-bridge - ''; - }; + protonmail-bridge = builder (import ./app.nix { inherit qtbase go goModules; }); + protonmail-bridge-headless = builder (import ./headless.nix { }); } diff --git a/pkgs/applications/networking/protonmail-bridge/headless.nix b/pkgs/applications/networking/protonmail-bridge/headless.nix new file mode 100644 index 0000000..6493b14 --- /dev/null +++ b/pkgs/applications/networking/protonmail-bridge/headless.nix @@ -0,0 +1,30 @@ +{}: + +rec { + pname = "protonmail-bridge-headless"; + + tags = "pmapi_prod nogui"; + + # FIXME: There's something fucky going on in the buildFlagsArray + # substitution. I shouldn't need to do this. + buildPhase = + let + t = "github.com/ProtonMail/proton-bridge/pkg/constants"; + in + '' + runHook preBuild + + go install \ + -tags="${tags}" \ + -ldflags="-X ${t}.Version=1.3.2 -X ${t}.Revision=unknown -X ${t}.BuildDate=unknown" \ + cmd/Desktop-Bridge/main.go + mv $GOPATH/bin/main $GOPATH/bin/Desktop-Bridge + + runHook postBuild + ''; + + # Fix up name. + postInstall = '' + mv $out/bin/Desktop-Bridge $out/bin/protonmail-bridge + ''; +}