protonmail-bridge: split into multiple files

This commit is contained in:
xeals 2020-10-15 21:49:24 +11:00
parent 8162d99dff
commit 304d3932f4
Signed by: xeals
GPG Key ID: A498C7AF27EC6B5C
4 changed files with 88 additions and 81 deletions

View File

@ -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 { };

View File

@ -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;
}

View File

@ -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 { });
}

View File

@ -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
'';
}