git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #151364 from matthiasbeyer/add-timetagger

Add timetagger

commit3cbdd13b11d040e5a660cb9ed2c754c4e9717a6c author0x4A6F <0x4A6F@users.noreply.github.com> dateSat 15 Jan 2022, 09:52 (5 years ago) parentfd5df0eab58c31
10 files changed+283
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+8 nixos/doc/manual/release-notes/rl-2205.section.md+2 nixos/modules/services/web-apps/timetagger.nix+80 pkgs/development/python-modules/asgineer/default.nix+32 pkgs/development/python-modules/itemdb/default.nix+26 pkgs/development/python-modules/pscript/default.nix+39 pkgs/development/python-modules/timetagger/default.nix+47 pkgs/servers/timetagger/default.nix+39 pkgs/top-level/all-packages.nix+2 pkgs/top-level/python-packages.nix+8
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+8
@@ -150,6 +150,14 @@
150150 <link linkend="opt-services.prosody-filer.enable">services.prosody-filer</link>.
151151 </para>
152152 </listitem>
153+ <listitem>
154+ <para>
155+ <link xlink:href="https://timetagger.app">timetagger</link>,
156+ an open source time-tracker with an intuitive user experience
157+ and powerful reporting.
158+ <link xlink:href="options.html#opt-services.timetagger.enable">services.timetagger</link>.
159+ </para>
160+ </listitem>
153161 </itemizedlist>
154162 </section>
155163 <section xml:id="sec-release-22.05-incompatibilities">
nixos/doc/manual/release-notes/rl-2205.section.md+2
@@ -46,6 +46,8 @@ In addition to numerous new and upgraded packages, this release has the followin
4646
4747- [prosody-filer](https://github.com/ThomasLeister/prosody-filer), a server for handling XMPP HTTP Upload requests. Available at [services.prosody-filer](#opt-services.prosody-filer.enable).
4848
49+- [timetagger](https://timetagger.app), an open source time-tracker with an intuitive user experience and powerful reporting. [services.timetagger](options.html#opt-services.timetagger.enable).
50+
4951## Backward Incompatibilities {#sec-release-22.05-incompatibilities}
5052
5153- `pkgs.ghc` now refers to `pkgs.targetPackages.haskellPackages.ghc`.
nixos/modules/services/web-apps/timetagger.nixnew file+80
@@ -0,0 +1,80 @@
1+{ config, lib, pkgs, ... }:
2+
3+let
4+ inherit (lib) mkEnableOption mkIf mkOption types literalExpression;
5+
6+ cfg = config.services.timetagger;
7+in {
8+
9+ options = {
10+ services.timetagger = {
11+ enable = mkOption {
12+ type = types.bool;
13+ default = false;
14+ description = ''
15+ Tag your time, get the insight
16+
17+ <note><para>
18+ This app does not do authentication.
19+ You must setup authentication yourself or run it in an environment where
20+ only allowed users have access.
21+ </para></note>
22+ '';
23+ };
24+
25+ bindAddr = mkOption {
26+ description = "Address to bind to.";
27+ type = types.str;
28+ default = "127.0.0.1";
29+ };
30+
31+ port = mkOption {
32+ description = "Port to bind to.";
33+ type = types.port;
34+ default = 8080;
35+ };
36+
37+ package = mkOption {
38+ description = ''
39+ Use own package for starting timetagger web application.
40+
41+ The ${literalExpression ''pkgs.timetagger''} package only provides a
42+ "run.py" script for the actual package
43+ ${literalExpression ''pkgs.python3Packages.timetagger''}.
44+
45+ If you want to provide a "run.py" script for starting timetagger
46+ yourself, you can do so with this option.
47+ If you do so, the 'bindAddr' and 'port' options are ignored.
48+ '';
49+
50+ default = pkgs.timetagger.override { addr = cfg.bindAddr; port = cfg.port; };
51+ defaultText = literalExpression ''
52+ pkgs.timetagger.override {
53+ addr = ${cfg.bindAddr};
54+ port = ${cfg.port};
55+ };
56+ '';
57+ type = types.package;
58+ };
59+ };
60+ };
61+
62+ config = mkIf cfg.enable {
63+ systemd.services.timetagger = {
64+ description = "Timetagger service";
65+ wantedBy = [ "multi-user.target" ];
66+
67+ serviceConfig = {
68+ User = "timetagger";
69+ Group = "timetagger";
70+ StateDirectory = "timetagger";
71+
72+ ExecStart = "${cfg.package}/bin/timetagger";
73+
74+ Restart = "on-failure";
75+ RestartSec = 1;
76+ };
77+ };
78+ };
79+}
80+
pkgs/development/python-modules/asgineer/default.nixnew file+32
@@ -0,0 +1,32 @@
1+{ lib
2+, buildPythonPackage
3+, fetchFromGitHub
4+, pytestCheckHook
5+, requests
6+}:
7+
8+buildPythonPackage rec {
9+ pname = "asgineer";
10+ version = "0.8.1";
11+
12+ # PyPI tarball doesn't include tests directory
13+ src = fetchFromGitHub {
14+ owner = "almarklein";
15+ repo = pname;
16+ rev = "v${version}";
17+ sha256 = "0hd1i9pc8m7sc8bkn31q4ygkmnl5vklrcziq9zkdiqaqm8clyhcx";
18+ };
19+
20+ checkInputs = [
21+ pytestCheckHook
22+ requests
23+ ];
24+
25+ meta = with lib; {
26+ description = "A really thin ASGI web framework";
27+ license = licenses.bsd2;
28+ homepage = "https://asgineer.readthedocs.io";
29+ maintainers = [ maintainers.matthiasbeyer ];
30+ };
31+}
32+
pkgs/development/python-modules/itemdb/default.nixnew file+26
@@ -0,0 +1,26 @@
1+{ lib
2+, buildPythonPackage
3+, fetchFromGitHub
4+}:
5+
6+buildPythonPackage rec {
7+ pname = "itemdb";
8+ version = "1.1.1";
9+
10+ # PyPI tarball doesn't include tests directory
11+ src = fetchFromGitHub {
12+ owner = "almarklein";
13+ repo = pname;
14+ rev = "v${version}";
15+ sha256 = "0ksad5j91nlbsn0a11clf994qz7r9ijand5hxnjhgd66i9hl3y78";
16+ };
17+
18+ meta = with lib; {
19+ description = "Easy transactional database for Python dicts, backed by SQLite";
20+ license = licenses.bsd2;
21+ homepage = "https://itemdb.readthedocs.io";
22+ maintainers = [ maintainers.matthiasbeyer ];
23+ };
24+}
25+
26+
pkgs/development/python-modules/pscript/default.nixnew file+39
@@ -0,0 +1,39 @@
1+{ lib
2+, buildPythonPackage
3+, fetchFromGitHub
4+, pytestCheckHook
5+, nodejs
6+}:
7+
8+buildPythonPackage rec {
9+ pname = "pscript";
10+ version = "0.7.6";
11+
12+ # PyPI tarball doesn't include tests directory
13+ src = fetchFromGitHub {
14+ owner = "flexxui";
15+ repo = pname;
16+ rev = "v${version}";
17+ sha256 = "169px5n4jjnpdn9y86f28qwd95bwf1q1rz0a1h3lb5nn5c6ym8c4";
18+ };
19+
20+ checkInputs = [
21+ pytestCheckHook
22+ nodejs
23+ ];
24+
25+ preCheck = ''
26+ # do not execute legacy tests
27+ rm -rf pscript_legacy
28+ '';
29+
30+ meta = with lib; {
31+ description = "Python to JavaScript compiler";
32+ license = licenses.bsd2;
33+ homepage = "https://pscript.readthedocs.io";
34+ maintainers = [ maintainers.matthiasbeyer ];
35+ };
36+}
37+
38+
39+
pkgs/development/python-modules/timetagger/default.nixnew file+47
@@ -0,0 +1,47 @@
1+{ lib
2+, python3Packages
3+, fetchFromGitHub
4+, pytestCheckHook
5+, requests
6+}:
7+
8+python3Packages.buildPythonPackage rec {
9+ pname = "timetagger";
10+ version = "22.1.2";
11+
12+ src = fetchFromGitHub {
13+ owner = "almarklein";
14+ repo = pname;
15+ rev = "v${version}";
16+ sha256 = "0xrajx0iij7r70ch17m4y6ydyh368dn6nbjsv74pn1x8frd686rw";
17+ };
18+
19+ meta = with lib; {
20+ homepage = "https://timetagger.app";
21+ license = licenses.gpl3;
22+ description = "Tag your time, get the insight";
23+ maintainers = with maintainers; [ matthiasbeyer ];
24+ };
25+
26+ checkInputs = [
27+ pytestCheckHook
28+ requests
29+ ];
30+
31+ preCheck = ''
32+ # https://github.com/NixOS/nixpkgs/issues/12591
33+ mkdir -p check-phase
34+ export HOME=$(pwd)/check-phase
35+ '';
36+
37+ propagatedBuildInputs = with python3Packages; [
38+ asgineer
39+ itemdb
40+ jinja2
41+ markdown
42+ pscript
43+ pyjwt
44+ uvicorn
45+ ];
46+
47+}
pkgs/servers/timetagger/default.nixnew file+39
@@ -0,0 +1,39 @@
1+{ lib
2+, pkgs
3+, python3Packages
4+, fetchFromGitHub
5+
6+, addr ? "127.0.0.1"
7+, port ? 8082
8+}:
9+
10+#
11+# Timetagger itself is a library that a user must write a "run.py" script for
12+# We provide a basic "run.py" script with this package, which simply starts
13+# timetagger.
14+#
15+
16+let
17+ tt = python3Packages.timetagger;
18+in
19+python3Packages.buildPythonPackage rec {
20+ pname = tt.name;
21+ version = tt.version;
22+ src = tt.src;
23+ meta = tt.meta;
24+
25+ propagatedBuildInputs = [ tt ]
26+ ++ (with python3Packages; [
27+ setuptools
28+ ]);
29+
30+ format = "custom";
31+ installPhase = ''
32+ mkdir -p $out/bin
33+ echo "#!${pkgs.python3}/bin/python3" >> $out/bin/timetagger
34+ cat run.py >> $out/bin/timetagger
35+ sed -Ei 's,0\.0\.0\.0:80,${addr}:${toString port},' $out/bin/timetagger
36+ chmod +x $out/bin/timetagger
37+ '';
38+}
39+
pkgs/top-level/all-packages.nix+2
@@ -10202,6 +10202,8 @@ with pkgs;
1020210202
1020310203 timetrap = callPackage ../applications/office/timetrap { };
1020410204
10205+ timetagger = callPackage ../servers/timetagger { };
10206+
1020510207 timekeeper = callPackage ../applications/office/timekeeper { };
1020610208
1020710209 timezonemap = callPackage ../development/libraries/timezonemap { };
pkgs/top-level/python-packages.nix+8
@@ -634,6 +634,8 @@ in {
634634
635635 asgi-csrf = callPackage ../development/python-modules/asgi-csrf { };
636636
637+ asgineer = callPackage ../development/python-modules/asgineer { };
638+
637639 asgiref = callPackage ../development/python-modules/asgiref { };
638640
639641 asmog = callPackage ../development/python-modules/asmog { };
@@ -4055,6 +4057,8 @@ in {
40554057
40564058 itemadapter = callPackage ../development/python-modules/itemadapter { };
40574059
4060+ itemdb = callPackage ../development/python-modules/itemdb { };
4061+
40584062 itemloaders = callPackage ../development/python-modules/itemloaders { };
40594063
40604064 iterm2 = callPackage ../development/python-modules/iterm2 { };
@@ -6332,6 +6336,8 @@ in {
63326336
63336337 psautohint = callPackage ../development/python-modules/psautohint { };
63346338
6339+ pscript = callPackage ../development/python-modules/pscript { };
6340+
63356341 psd-tools = callPackage ../development/python-modules/psd-tools { };
63366342
63376343 psutil = callPackage ../development/python-modules/psutil { };
@@ -9713,6 +9719,8 @@ in {
97139719
97149720 timeout-decorator = callPackage ../development/python-modules/timeout-decorator { };
97159721
9722+ timetagger = callPackage ../development/python-modules/timetagger { };
9723+
97169724 timezonefinder = callPackage ../development/python-modules/timezonefinder { };
97179725
97189726 tinycss2 = callPackage ../development/python-modules/tinycss2 { };