git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #18868 from RonnyPfannschmidt/enpass

enpass: init at 5.3.0

commit905239db28e1b82625c325059b6c305c90d44c24 authorJörg Thalheim <joerg@higgsboson.tk> dateMon 10 Oct 2016, 07:56 (10 years ago) parent709840498895f5
5 files changed+216
lib/maintainers.nix+1 pkgs/tools/security/enpass/data.json+12 pkgs/tools/security/enpass/default.nix+106 pkgs/tools/security/enpass/update_script.py+95 pkgs/top-level/all-packages.nix+2
lib/maintainers.nix+1
@@ -368,6 +368,7 @@
368368 roblabla = "Robin Lambertz <robinlambertz+dev@gmail.com>";
369369 roconnor = "Russell O'Connor <roconnor@theorem.ca>";
370370 romildo = "José Romildo Malaquias <malaquias@gmail.com>";
371+ ronny = "Ronny Pfannschmidt <nixos@ronnypfannschmidt.de>";
371372 rszibele = "Richard Szibele <richard_szibele@hotmail.com>";
372373 rushmorem = "Rushmore Mushambi <rushmore@webenchanter.com>";
373374 rvl = "Rodney Lorrimar <dev+nix@rodney.id.au>";
pkgs/tools/security/enpass/data.jsonnew file+12
@@ -0,0 +1,12 @@
1+{
2+ "amd64": {
3+ "path": "pool/main/e/enpass/enpass_5.3.0_amd64.deb",
4+ "sha256": "d9da061c6456281da836bdd78bdb7baeced4b7f1805bb2495e4f1d15038cf86b",
5+ "version": "5.3.0"
6+ },
7+ "i386": {
8+ "path": "pool/main/e/enpass/enpass_5.3.0_i386.deb",
9+ "sha256": "58d9f3b83c2da477c13976e1826d112236eabd46a389de7e8767ee99ac41f469",
10+ "version": "5.3.0"
11+ }
12+}
pkgs/tools/security/enpass/default.nixnew file+106
@@ -0,0 +1,106 @@
1+{stdenv, system, fetchurl, dpkg, openssl, xorg
2+, glib, mesa, libpulseaudio, zlib, dbus, fontconfig, freetype
3+, gtk2, pango, atk, cairo, gdk_pixbuf, jasper, xkeyboardconfig
4+, makeWrapper , makeDesktopItem, python, pythonPackages, lib}:
5+assert system == "i686-linux" || system == "x86_64-linux";
6+let
7+ all_data = (with builtins; fromJSON (readFile ./data.json));
8+ system_map = {
9+ i686-linux = "i386";
10+ x86_64-linux = "amd64";
11+ };
12+
13+ data = (with builtins; getAttr (getAttr system system_map) all_data);
14+
15+ baseUrl = http://repo.sinew.in;
16+
17+ # used of both wrappers and libpath
18+ libPath = lib.makeLibraryPath (with xorg; [
19+ openssl
20+ mesa
21+ fontconfig
22+ freetype
23+ libpulseaudio
24+ zlib
25+ dbus
26+ libX11
27+ libXi
28+ libSM
29+ libICE
30+ libXext
31+ libXrender
32+ libXScrnSaver
33+ glib
34+ gtk2
35+ pango
36+ cairo
37+ atk
38+ gdk_pixbuf
39+ jasper
40+ stdenv.cc.cc
41+ ]);
42+ package = stdenv.mkDerivation rec {
43+
44+ inherit (data) version;
45+ name = "enpass-${version}";
46+
47+ desktopItem = makeDesktopItem {
48+ name = "Enpass";
49+ exec = "$out/bin/Enpass";
50+ #icon = "Enpass";
51+ desktopName = "Enpass";
52+ genericName = "Password manager";
53+ categories = "Application;Security;";
54+ };
55+
56+
57+ src = fetchurl {
58+ inherit (data) sha256;
59+ url = "${baseUrl}/${data.path}";
60+ };
61+
62+ meta = {
63+ description = "a well known password manager";
64+ homepage = https://www.enpass.io/;
65+ maintainer = lib.maintainers.ronny;
66+ license = lib.licenses.unfree;
67+ platforms = lib.platforms.linux;
68+ };
69+
70+ buildInputs = [makeWrapper dpkg];
71+ phases = [ "unpackPhase" "installPhase" ];
72+
73+ unpackPhase = "dpkg -X $src .";
74+ installPhase=''
75+ mkdir $out
76+ cp -r opt/Enpass/* $out
77+
78+ # Make desktop item
79+ mkdir -p "$out"/share/applications
80+ cp "$desktopItem"/share/applications/* "$out"/share/applications/
81+ mkdir -p "$out"/share/icons
82+
83+ patchelf \
84+ --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
85+ $out/bin/Enpass
86+
87+ wrapProgram $out/bin/Enpass \
88+ --set LD_LIBRARY_PATH "${libPath}:$out/lib:$out/plugins/sqldrivers" \
89+ --set QT_PLUGIN_PATH "$out/plugins" \
90+ --set QT_QPA_PLATFORM_PLUGIN_PATH "$out/plugins/platforms" \
91+ --set QT_XKB_CONFIG_ROOT "${xkeyboardconfig}/share/X11/xkb"
92+ '';
93+ };
94+ updater = {
95+ update = stdenv.mkDerivation rec {
96+ name = "enpass-update-script";
97+ SCRIPT =./update_script.py;
98+
99+ buildInputs = with pythonPackages; [python requests pathlib2 six attrs ];
100+ shellHook = ''
101+ exec python $SCRIPT --target pkgs/tools/security/enpass/data.json --repo ${baseUrl}
102+ '';
103+
104+ };
105+ };
106+in (package // {refresh = updater;})
pkgs/tools/security/enpass/update_script.pynew file+95
@@ -0,0 +1,95 @@
1+from __future__ import print_function
2+
3+
4+import argparse
5+import bz2
6+import email
7+import json
8+import logging
9+
10+from itertools import product
11+from operator import itemgetter
12+
13+import attr
14+import pkg_resources
15+
16+from pathlib2 import Path
17+from requests import Session
18+from six.moves.urllib_parse import urljoin
19+
20+
21+@attr.s
22+class ReleaseElement(object):
23+ sha256 = attr.ib(repr=False)
24+ size = attr.ib(convert=int)
25+ path = attr.ib()
26+
27+log = logging.getLogger('enpass.updater')
28+
29+
30+parser = argparse.ArgumentParser()
31+parser.add_argument('--repo')
32+parser.add_argument('--target', type=Path)
33+
34+
35+session = Session()
36+
37+
38+def parse_bz2_msg(msg):
39+ msg = bz2.decompress(msg)
40+ if '\n\n' in msg:
41+ parts = msg.split('\n\n')
42+ return list(map(email.message_from_string, parts))
43+ return email.message_from_string(msg)
44+
45+
46+def fetch_meta(repo, name, parse=email.message_from_string, split=False):
47+ url = urljoin(repo, 'dists/stable', name)
48+ response = session.get("{repo}/dists/stable/{name}".format(**locals()))
49+ return parse(response.content)
50+
51+
52+def fetch_filehashes(repo, path):
53+ meta = fetch_meta(repo, path, parse=parse_bz2_msg)
54+ for item in meta:
55+ yield {
56+ 'version': pkg_resources.parse_version(str(item['Version'])),
57+ 'path': item['Filename'],
58+ 'sha256': item['sha256'],
59+ }
60+
61+
62+def fetch_archs(repo):
63+ m = fetch_meta(repo, 'Release')
64+
65+ architectures = m['Architectures'].split()
66+ elements = [ReleaseElement(*x.split()) for x in m['SHA256'].splitlines()]
67+ elements = [x for x in elements if x.path.endswith('bz2')]
68+
69+ for arch, elem in product(architectures, elements):
70+ if arch in elem.path:
71+ yield arch, max(fetch_filehashes(repo, elem.path),
72+ key=itemgetter('version'))
73+
74+
75+class OurVersionEncoder(json.JSONEncoder):
76+ def default(self, obj):
77+ # the other way around to avoid issues with
78+ # newer setuptools having strict/legacy versions
79+ if not isinstance(obj, (dict, str)):
80+ return str(obj)
81+ return json.JSONEncoder.default(self, obj)
82+
83+
84+def main(repo, target):
85+ logging.basicConfig(level=logging.DEBUG)
86+ with target.open(mode='wb') as fp:
87+ json.dump(
88+ dict(fetch_archs(repo)), fp,
89+ cls=OurVersionEncoder,
90+ indent=2,
91+ sort_keys=True)
92+
93+
94+opts = parser.parse_args()
95+main(opts.repo, opts.target)
pkgs/top-level/all-packages.nix+2
@@ -501,6 +501,8 @@ in
501501
502502 elvish = callPackage ../shells/elvish { };
503503
504+ enpass = callPackage ../tools/security/enpass { };
505+
504506 genymotion = callPackage ../development/mobile/genymotion { };
505507
506508 grc = callPackage ../tools/misc/grc { };