Skip to content

Commit

Permalink
got-your-back: init at 2015-03-18
Browse files Browse the repository at this point in the history
  • Loading branch information
wizeman committed Dec 1, 2015
1 parent d76c99d commit 1121245
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
74 changes: 74 additions & 0 deletions pkgs/tools/networking/got-your-back/default.nix
@@ -0,0 +1,74 @@
{ pkgs, fetchFromGitHub, buildPythonPackage, pythonPackages }:

buildPythonPackage rec {
version = "2015-03-18";
name = "got-your-back-${version}";

src = fetchFromGitHub {
owner = "jay0lee";
repo = "got-your-back";
rev = "3b087e78c330f43574ba388ffb03326280ac7d40";
sha256 = "1m45g7q6dg9m99nx6fr520iyviliafwdjq6ckczry8l4wjx49wwv";
};

doCheck = false;

propagatedBuildInputs = with pythonPackages; [
sqlite3
];

patches = [ ./homedir.patch ];

postPatch = ''
rm setup.py setup-64.py
substituteInPlace gyb.py \
--replace "CLIENT_SECRETS = getProgPath()+" \
"CLIENT_SECRETS = \"$out/share/\"+" \
--replace "ca_certs=getProgPath()+" \
"ca_certs=\"$out/share/\"+" \
--replace "certFile = getProgPath()+" \
"certFile = \"$out/share/\"+"
echo '#!/usr/bin/env python' > gyb
tail -n +2 gyb.py >> gyb
cat <<EOF > ./setup.py
#!/usr/bin/env python
from distutils.core import setup
import glob
setup(name='gyb',
version='${version}',
scripts=['gyb'],
py_modules=[x[:-3] for x in glob.glob('*.py') if x != 'setup.py'],
packages=['apiclient', 'httplib2', 'oauth2client', 'uritemplate'],
data_files=[('share', ['client_secrets.json', 'cacert.pem'])]
)
EOF
'';

# `wrapPythonPrograms` inserts code before the module's docstring, which means
# that python won't recognize it as a docstring anymore (i.e. `__doc__` will
# be `None`). This breaks the `--help` command.
#
# Since the added code is not really needed, let's delete it.
postPhases = [ "fixScript" ];
fixScript = ''
sed -i "$out/bin/.gyb-wrapped" -e '{
/import sys; sys.argv/d
}'
'';

meta = {
description = "Command line tool for backing up your Gmail messages to your local computer";
longDescription = ''
Got Your Back (GYB) is a command line tool for backing up your Gmail
messages to your local computer. It uses the standard IMAP protocol but
also takes advantage of some custom Gmail IMAP extensions.
'';
homepage = https://github.com/jay0lee/got-your-back;
license = pkgs.lib.licenses.asl20;
};
}
17 changes: 17 additions & 0 deletions pkgs/tools/networking/got-your-back/homedir.patch
@@ -0,0 +1,17 @@
diff --git a/gyb.py b/gyb.py
index e40f04f..4a7d509 100644
--- a/gyb.py
+++ b/gyb.py
@@ -150,11 +150,7 @@ def win32_unicode_argv():
return [argv[i] for i in xrange(start, argc.value)]

def getProgPath():
- if os.path.abspath('/') != -1:
- divider = '/'
- else:
- divider = '\\'
- return os.path.dirname(os.path.realpath(sys.argv[0]))+divider
+ return os.getenv("HOME") + "/.gyb/"

def batch(iterable, size):
sourceiter = iter(iterable)
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -1665,6 +1665,8 @@ let

google-fonts = callPackage ../data/fonts/google-fonts { };

got-your-back = callPackage ../tools/networking/got-your-back { };

gource = callPackage ../applications/version-management/gource { };

gpart = callPackage ../tools/filesystems/gpart { };
Expand Down

0 comments on commit 1121245

Please sign in to comment.