aboutsummaryrefslogtreecommitdiff
path: root/pkgs
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-04-26 01:32:07 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-04-26 01:32:07 +0200
commit8c4f6e37479002818bcfe7381cd4e4b47fd2d1fb (patch)
tree8d032273fb3b5e4216b021795256e79dffe0b667 /pkgs
parentc79bb68270abd6e5a59e36bf09d64b2eb0d23fb8 (diff)
downloadNix-8c4f6e37479002818bcfe7381cd4e4b47fd2d1fb.tar.gz
Nix-8c4f6e37479002818bcfe7381cd4e4b47fd2d1fb.tar.zst
Nix-8c4f6e37479002818bcfe7381cd4e4b47fd2d1fb.zip
Start splitting nix environment to smaller files
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/mtop/default.nix24
-rw-r--r--pkgs/note/default.nix18
-rw-r--r--pkgs/terminal-velocity/default.nix33
-rw-r--r--pkgs/terminal-velocity/fix_build.patch21
-rw-r--r--pkgs/terminal-velocity/python3_support.patch215
-rw-r--r--pkgs/terminal-velocity/sort_found_notes.patch73
-rw-r--r--pkgs/tiv/default.nix19
-rw-r--r--pkgs/tiv/tiv_builder.sh8
8 files changed, 411 insertions, 0 deletions
diff --git a/pkgs/mtop/default.nix b/pkgs/mtop/default.nix
new file mode 100644
index 0000000..4a89430
--- /dev/null
+++ b/pkgs/mtop/default.nix
@@ -0,0 +1,24 @@
1{ buildPerlPackage, fetchurl, perlPackages, lib }:
2buildPerlPackage rec {
3 name = "mtop-${version}";
4 version = "0.6.6";
5 src = fetchurl {
6 url = "http://downloads.sourceforge.net/project/mtop/mtop/v${version}/mtop-${version}.tar.gz";
7 sha256 = "0x0x5300b1j9i0xxk8rsrki0pspyzj2vylhzv8qg3l6j26aw0zrf";
8 };
9 outputs = ["out"];
10 buildInputs = with perlPackages; [ DBI DBDmysql Curses ];
11
12 postInstall = ''
13 cd "$out"
14 preConfigure || true
15 '';
16
17 meta = with lib; {
18 description = "MySQL top (monitor and examine slow queries)";
19 homepage = http://mtop.sourceforge.net/;
20 license = licenses.gpl3;
21 maintainers = with maintainers; [ { name = "Marc Prewitt"; email = "mprewitt@chelsea.net"; } ];
22 platforms = platforms.unix;
23 };
24}
diff --git a/pkgs/note/default.nix b/pkgs/note/default.nix
new file mode 100644
index 0000000..0c422bc
--- /dev/null
+++ b/pkgs/note/default.nix
@@ -0,0 +1,18 @@
1{ lib, buildPerlPackage, fetchurl, perlPackages }:
2buildPerlPackage rec {
3 name = "note-1.3.26";
4 src = fetchurl {
5 url = "mirror://cpan/authors/id/T/TL/TLINDEN/${name}.tar.gz";
6 sha256 = "1h645rnb5vpms48fcyzvp7cwwcbf9k5xq49w2bpniyzzgk2brjrq";
7 };
8 outputs = ["out" "man"];
9 propagatedBuildInputs = with perlPackages; [ YAML ];
10
11 meta = with lib; {
12 description = "A perl script for maintaining notes";
13 homepage = http://www.daemon.de/NOTE;
14 license = licenses.gpl3;
15 maintainers = with maintainers; [ { name = "T.v.Dein"; email = "tlinden@cpan.org"; } ];
16 platforms = platforms.unix;
17 };
18}
diff --git a/pkgs/terminal-velocity/default.nix b/pkgs/terminal-velocity/default.nix
new file mode 100644
index 0000000..9e79dee
--- /dev/null
+++ b/pkgs/terminal-velocity/default.nix
@@ -0,0 +1,33 @@
1{ python36Packages }:
2with python36Packages;
3buildPythonApplication rec {
4 pname = "terminal-velocity-git";
5 version = "0.2.0";
6 src = fetchPypi {
7 inherit pname version;
8 sha256 = "13yrkcmvh5h5fwnai61sbmqkrjyisz08n62pq0ada2lyyqf7g6b9";
9 };
10
11 patches = [
12 ./sort_found_notes.patch
13 ./python3_support.patch
14 # FIXME: update this patch when version changes
15 ./fix_build.patch
16 ];
17
18 propagatedBuildInputs = [
19 chardet
20 urwid
21 (sh.overridePythonAttrs { doCheck = false; })
22 pyyaml
23 ];
24 buildInputs = [
25 m2r
26 (restructuredtext_lint.overridePythonAttrs { doCheck = false; })
27 pygments
28 ];
29
30 postInstall = ''
31 rm $out/bin/terminal_velocity
32 '';
33}
diff --git a/pkgs/terminal-velocity/fix_build.patch b/pkgs/terminal-velocity/fix_build.patch
new file mode 100644
index 0000000..b08e0c4
--- /dev/null
+++ b/pkgs/terminal-velocity/fix_build.patch
@@ -0,0 +1,21 @@
1commit a64bf3d58f6ba7f5fa72fe5b89a3973cac0c1a99
2Author: Ismaël Bouya <ismael.bouya@normalesup.org>
3Date: Sat Mar 9 20:13:52 2019 +0100
4
5 Remove mister_bump dependency
6
7diff --git a/setup.py b/setup.py
8index 84a99e9..a783dff 100644
9--- a/setup.py
10+++ b/setup.py
11@@ -1,7 +1,9 @@
12 from setuptools import setup
13 from m2r import parse_from_file
14 import restructuredtext_lint
15-from mister_bump import bump
16+
17+def bump():
18+ return "0.2.0"
19
20 # Parser README.md into reStructuredText format
21 rst_readme = parse_from_file('README.md')
diff --git a/pkgs/terminal-velocity/python3_support.patch b/pkgs/terminal-velocity/python3_support.patch
new file mode 100644
index 0000000..bd4aec7
--- /dev/null
+++ b/pkgs/terminal-velocity/python3_support.patch
@@ -0,0 +1,215 @@
1commit 6ca19964b9e8a7866fd7e21a3dac9ccd35f0d434
2Author: Ismaël Bouya <ismael.bouya@normalesup.org>
3Date: Sat Mar 9 20:13:18 2019 +0100
4
5 Add python3 support
6
7diff --git a/terminal_velocity/notebook.py b/terminal_velocity/notebook.py
8index b6226dc..11f76de 100644
9--- a/terminal_velocity/notebook.py
10+++ b/terminal_velocity/notebook.py
11@@ -60,51 +60,6 @@ import sys
12 import chardet
13
14
15-def unicode_or_bust(raw_text):
16- """Return the given raw text data decoded to unicode.
17-
18- If the text cannot be decoded, return None.
19-
20- """
21- encodings = ["utf-8"]
22- for encoding in (sys.getfilesystemencoding(), sys.getdefaultencoding()):
23- # I would use a set for this, but they don't maintain order.
24- if encoding not in encodings:
25- encodings.append(encoding)
26-
27- for encoding in encodings:
28- if encoding: # getfilesystemencoding() may return None
29- try:
30- decoded = unicode(raw_text, encoding=encoding)
31- return decoded
32- except UnicodeDecodeError:
33- pass
34-
35- # If none of those guesses worked, let chardet have a go.
36- encoding = chardet.detect(raw_text)["encoding"]
37- if encoding and encoding not in encodings:
38- try:
39- decoded = unicode(raw_text, encoding=encoding)
40- logger.debug("File decoded with chardet, encoding was {0}".format(
41- encoding))
42- return decoded
43- except UnicodeDecodeError:
44- pass
45- except LookupError:
46- pass
47-
48- # I've heard that decoding with cp1252 never fails, so try that last.
49- try:
50- decoded = unicode(raw_text, encoding="cp1252")
51- logger.debug("File decoded with encoding cp1252")
52- return decoded
53- except UnicodeDecodeError:
54- pass
55-
56- # If nothing worked then give up.
57- return None
58-
59-
60 class Error(Exception):
61 """Base class for exceptions in this module."""
62 pass
63@@ -192,12 +147,12 @@ class PlainTextNote(object):
64 # subdirs) if they don't exist.
65 directory = os.path.split(self.abspath)[0]
66 if not os.path.isdir(directory):
67- logger.debug(u"'{0} doesn't exist, creating it".format(directory))
68+ logger.debug("'{0} doesn't exist, creating it".format(directory))
69 try:
70 os.makedirs(directory)
71 except os.error as e:
72 raise NewNoteError(
73- u"{0} could not be created: {1}".format(directory, e))
74+ "{0} could not be created: {1}".format(directory, e))
75
76 # Create an empty file if the file doesn't exist.
77 open(self.abspath, 'a')
78@@ -217,11 +172,11 @@ class PlainTextNote(object):
79
80 @property
81 def contents(self):
82- contents = unicode_or_bust(open(self.abspath, "r").read())
83+ contents = open(self.abspath, "rb").read().decode(errors='ignore')
84 if contents is None:
85 logger.error(
86- u"Could not decode file contents: {0}".format(self.abspath))
87- return u""
88+ "Could not decode file contents: {0}".format(self.abspath))
89+ return ""
90 else:
91 return contents
92
93@@ -322,12 +277,12 @@ class PlainTextNoteBook(object):
94
95 # Create notebook_dir if it doesn't exist.
96 if not os.path.isdir(self.path):
97- logger.debug(u"'{0} doesn't exist, creating it".format(self.path))
98+ logger.debug("'{0} doesn't exist, creating it".format(self.path))
99 try:
100 os.makedirs(self.path)
101 except os.error as e:
102 raise NewNoteBookError(
103- u"{0} could not be created: {1}".format(self.path, e))
104+ "{0} could not be created: {1}".format(self.path, e))
105 else:
106 # TODO: Check that self.path is a directory, if not raise.
107 pass
108@@ -358,13 +313,12 @@ class PlainTextNoteBook(object):
109 abspath = os.path.join(root, filename)
110 relpath = os.path.relpath(abspath, self.path)
111 relpath, ext = os.path.splitext(relpath)
112- unicode_relpath = unicode_or_bust(relpath)
113 if relpath is None:
114 # The filename could not be decoded.
115 logger.error(
116 "Could not decode filename: {0}".format(relpath))
117 else:
118- self.add_new(title=unicode_relpath, extension=ext)
119+ self.add_new(title=relpath, extension=ext)
120
121 @property
122 def path(self):
123@@ -418,7 +372,7 @@ class PlainTextNoteBook(object):
124 for note in self._notes:
125 if note.title == title and note.extension == extension:
126 raise NoteAlreadyExistsError(
127- u"Note already in NoteBook: {0}".format(note.title))
128+ "Note already in NoteBook: {0}".format(note.title))
129
130 # Ok, add the note.
131 note = PlainTextNote(title, self, extension)
132diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py
133index 5f0e213..9234bea 100755
134--- a/terminal_velocity/terminal_velocity.py
135+++ b/terminal_velocity/terminal_velocity.py
136@@ -1,7 +1,7 @@
137-#!/usr/bin/env python2
138+#!/usr/bin/env python3
139 """A fast note-taking app for the UNIX terminal"""
140 from __future__ import print_function
141-import ConfigParser
142+import configparser
143 import argparse
144 import os
145 import logging
146@@ -9,9 +9,9 @@ import logging.handlers
147 import sys
148
149 #import terminal_velocity.urwid_ui as urwid_ui
150-import urwid_ui
151+from . import urwid_ui
152
153-from git import get_git_project_config, git_project_is_configured, fetch_changes, push_changes
154+from .git import get_git_project_config, git_project_is_configured, fetch_changes, push_changes
155
156
157 def startup():
158@@ -37,7 +37,7 @@ def main():
159
160 # Parse the config file.
161 config_file = os.path.abspath(os.path.expanduser(args.config))
162- config = ConfigParser.SafeConfigParser()
163+ config = configparser.ConfigParser()
164 config.read(config_file)
165 defaults = dict(config.items('DEFAULT'))
166
167diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py
168index caebcb9..89bab35 100644
169--- a/terminal_velocity/urwid_ui.py
170+++ b/terminal_velocity/urwid_ui.py
171@@ -10,7 +10,7 @@ import logging
172 logger = logging.getLogger(__name__)
173
174 import urwid
175-import notebook
176+from . import notebook
177
178
179 palette = [
180@@ -27,8 +27,6 @@ def system(cmd, loop):
181
182 loop.screen.stop()
183
184- cmd = u"{0}".format(cmd)
185- cmd = cmd.encode("utf-8") # FIXME: Correct encoding?
186 safe_cmd = shlex.split(cmd)
187
188 logger.debug("System command: {0}".format(safe_cmd))
189@@ -114,7 +112,7 @@ class AutocompleteWidget(urwid.Edit):
190
191 # When search bar is empty show placeholder text.
192 if not self.edit_text and not self.autocomplete_text:
193- placeholder_text = u"Find or Create"
194+ placeholder_text = "Find or Create"
195 return (placeholder_text,
196 [("placeholder", len(placeholder_text))])
197
198@@ -186,7 +184,7 @@ class NoteFilterListBox(urwid.ListBox):
199
200 def render(self, size, focus=False):
201 if len(self.list_walker) == 0:
202- placeholder = placeholder_text(u"No matching notes, press Enter "
203+ placeholder = placeholder_text("No matching notes, press Enter "
204 "to create a new note")
205 return placeholder.render(size)
206 return super(NoteFilterListBox, self).render(size, self.fake_focus)
207@@ -399,7 +397,7 @@ class MainFrame(urwid.Frame):
208 # If the user has no notes yet show some placeholder text, otherwise
209 # show the note list.
210 if len(self.notebook) == 0:
211- self.body = placeholder_text(u"You have no notes yet, to create "
212+ self.body = placeholder_text("You have no notes yet, to create "
213 "a note type a note title then press Enter")
214 else:
215 self.body = urwid.Padding(self.list_box, left=1, right=1)
diff --git a/pkgs/terminal-velocity/sort_found_notes.patch b/pkgs/terminal-velocity/sort_found_notes.patch
new file mode 100644
index 0000000..2bc563c
--- /dev/null
+++ b/pkgs/terminal-velocity/sort_found_notes.patch
@@ -0,0 +1,73 @@
1commit 0f9df37046e58c8963aff93c649e5d3dbf2202bd
2Author: Ismaël Bouya <ismael.bouya@normalesup.org>
3Date: Sat Mar 9 20:11:46 2019 +0100
4
5 Add sorting option
6
7diff --git a/terminal_velocity/terminal_velocity.py b/terminal_velocity/terminal_velocity.py
8index a53eda3..5f0e213 100755
9--- a/terminal_velocity/terminal_velocity.py
10+++ b/terminal_velocity/terminal_velocity.py
11@@ -90,6 +90,10 @@ the default default will be used"""
12 default=defaults.get("log_file", "~/.tvlog"),
13 help="the file to log to (default: %(default)s)")
14
15+ parser.add_argument("-s", "--sort", dest="sort", action="store",
16+ default=defaults.get("sort", "date"),
17+ help="the note sorting rules. Possible values: date, title (default: %(default)s)")
18+
19 parser.add_argument("-p", "--print-config", dest="print_config",
20 action="store_true", default=False,
21 help="print your configuration settings then exit")
22@@ -138,7 +142,7 @@ the default default will be used"""
23 try:
24 urwid_ui.launch(notes_dir=args.notes_dir, editor=args.editor,
25 extension=args.extension, extensions=args.extensions,
26- exclude=args.exclude)
27+ exclude=args.exclude, sort=args.sort)
28 except KeyboardInterrupt:
29 # Run the shutdown hook
30 shutdown()
31diff --git a/terminal_velocity/urwid_ui.py b/terminal_velocity/urwid_ui.py
32index 34cf4f6..caebcb9 100644
33--- a/terminal_velocity/urwid_ui.py
34+++ b/terminal_velocity/urwid_ui.py
35@@ -237,11 +237,12 @@ class NoteFilterListBox(urwid.ListBox):
36 class MainFrame(urwid.Frame):
37 """The topmost urwid widget."""
38
39- def __init__(self, notes_dir, editor, extension, extensions, exclude=None):
40+ def __init__(self, notes_dir, editor, extension, extensions, exclude=None, sort="date"):
41
42 self.editor = editor
43 self.notebook = notebook.PlainTextNoteBook(notes_dir, extension,
44 extensions, exclude=exclude)
45+ self.sort = sort
46
47 # Don't filter the note list when the text in the search box changes.
48 self.suppress_filter = False
49@@ -408,7 +409,10 @@ class MainFrame(urwid.Frame):
50
51 # Sort the notes.
52 # TODO: Support different sort orderings.
53- matching_notes.sort(key=lambda x: x.mtime, reverse=True)
54+ if self.sort == "title":
55+ matching_notes.sort(key=lambda x: x.title)
56+ else:
57+ matching_notes.sort(key=lambda x: x.mtime, reverse=True)
58
59 # Tell the list box to show only the matching notes.
60 self.list_box.filter(matching_notes)
61@@ -433,10 +437,10 @@ class MainFrame(urwid.Frame):
62 self.selected_note = note
63
64
65-def launch(notes_dir, editor, extension, extensions, exclude=None):
66+def launch(notes_dir, editor, extension, extensions, exclude=None, sort="date"):
67 """Launch the user interface."""
68
69- frame = MainFrame(notes_dir, editor, extension, extensions, exclude=exclude)
70+ frame = MainFrame(notes_dir, editor, extension, extensions, exclude=exclude, sort=sort)
71 loop = urwid.MainLoop(frame, palette)
72 frame.loop = loop
73 loop.run()
diff --git a/pkgs/tiv/default.nix b/pkgs/tiv/default.nix
new file mode 100644
index 0000000..c03aabe
--- /dev/null
+++ b/pkgs/tiv/default.nix
@@ -0,0 +1,19 @@
1{ buildPerlPackage, fetchurl, perlPackages }:
2buildPerlPackage rec {
3 name = "tiv-${version}";
4 version = "2015";
5 src = fetchurl {
6 url = "http://xyne.archlinux.ca/projects/tiv/src/tiv-${version}.tar.xz";
7 sha256 = "1vq073v7z7vmcd57lhs4rf4jasji69cpjgkz4dykp94a77p1qq90";
8 };
9
10 outputs = ["out"];
11 buildInputs = with perlPackages; [ PerlMagick ];
12 perlPreHookScript = ./tiv_builder.sh;
13 perlPreHook = ''
14 source $perlPreHookScript
15 '';
16 installPhase = ''
17 install -Dm755 tiv "$out/bin/tiv"
18 '';
19}
diff --git a/pkgs/tiv/tiv_builder.sh b/pkgs/tiv/tiv_builder.sh
new file mode 100644
index 0000000..ea16682
--- /dev/null
+++ b/pkgs/tiv/tiv_builder.sh
@@ -0,0 +1,8 @@
1orig=$(declare -f preConfigure)
2new_name="preConfigure2 ${orig#preConfigure}"
3eval "$new_name"
4
5preConfigure() {
6 preConfigure2 || true
7}
8