Merge pull request #151364 from matthiasbeyer/add-timetagger

Add timetagger
This commit is contained in:
0x4A6F 2022-01-15 09:52:21 +01:00 committed by GitHub
commit 3cbdd13b11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 283 additions and 0 deletions

View File

@ -150,6 +150,14 @@
<link linkend="opt-services.prosody-filer.enable">services.prosody-filer</link>.
</para>
</listitem>
<listitem>
<para>
<link xlink:href="https://timetagger.app">timetagger</link>,
an open source time-tracker with an intuitive user experience
and powerful reporting.
<link xlink:href="options.html#opt-services.timetagger.enable">services.timetagger</link>.
</para>
</listitem>
</itemizedlist>
</section>
<section xml:id="sec-release-22.05-incompatibilities">

View File

@ -46,6 +46,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- [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).
- [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).
## Backward Incompatibilities {#sec-release-22.05-incompatibilities}
- `pkgs.ghc` now refers to `pkgs.targetPackages.haskellPackages.ghc`.

View File

@ -0,0 +1,80 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkEnableOption mkIf mkOption types literalExpression;
cfg = config.services.timetagger;
in {
options = {
services.timetagger = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Tag your time, get the insight
<note><para>
This app does not do authentication.
You must setup authentication yourself or run it in an environment where
only allowed users have access.
</para></note>
'';
};
bindAddr = mkOption {
description = "Address to bind to.";
type = types.str;
default = "127.0.0.1";
};
port = mkOption {
description = "Port to bind to.";
type = types.port;
default = 8080;
};
package = mkOption {
description = ''
Use own package for starting timetagger web application.
The ${literalExpression ''pkgs.timetagger''} package only provides a
"run.py" script for the actual package
${literalExpression ''pkgs.python3Packages.timetagger''}.
If you want to provide a "run.py" script for starting timetagger
yourself, you can do so with this option.
If you do so, the 'bindAddr' and 'port' options are ignored.
'';
default = pkgs.timetagger.override { addr = cfg.bindAddr; port = cfg.port; };
defaultText = literalExpression ''
pkgs.timetagger.override {
addr = ${cfg.bindAddr};
port = ${cfg.port};
};
'';
type = types.package;
};
};
};
config = mkIf cfg.enable {
systemd.services.timetagger = {
description = "Timetagger service";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "timetagger";
Group = "timetagger";
StateDirectory = "timetagger";
ExecStart = "${cfg.package}/bin/timetagger";
Restart = "on-failure";
RestartSec = 1;
};
};
};
}

View File

@ -0,0 +1,32 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, pytestCheckHook
, requests
}:
buildPythonPackage rec {
pname = "asgineer";
version = "0.8.1";
# PyPI tarball doesn't include tests directory
src = fetchFromGitHub {
owner = "almarklein";
repo = pname;
rev = "v${version}";
sha256 = "0hd1i9pc8m7sc8bkn31q4ygkmnl5vklrcziq9zkdiqaqm8clyhcx";
};
checkInputs = [
pytestCheckHook
requests
];
meta = with lib; {
description = "A really thin ASGI web framework";
license = licenses.bsd2;
homepage = "https://asgineer.readthedocs.io";
maintainers = [ maintainers.matthiasbeyer ];
};
}

View File

@ -0,0 +1,26 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
}:
buildPythonPackage rec {
pname = "itemdb";
version = "1.1.1";
# PyPI tarball doesn't include tests directory
src = fetchFromGitHub {
owner = "almarklein";
repo = pname;
rev = "v${version}";
sha256 = "0ksad5j91nlbsn0a11clf994qz7r9ijand5hxnjhgd66i9hl3y78";
};
meta = with lib; {
description = "Easy transactional database for Python dicts, backed by SQLite";
license = licenses.bsd2;
homepage = "https://itemdb.readthedocs.io";
maintainers = [ maintainers.matthiasbeyer ];
};
}

View File

@ -0,0 +1,39 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, pytestCheckHook
, nodejs
}:
buildPythonPackage rec {
pname = "pscript";
version = "0.7.6";
# PyPI tarball doesn't include tests directory
src = fetchFromGitHub {
owner = "flexxui";
repo = pname;
rev = "v${version}";
sha256 = "169px5n4jjnpdn9y86f28qwd95bwf1q1rz0a1h3lb5nn5c6ym8c4";
};
checkInputs = [
pytestCheckHook
nodejs
];
preCheck = ''
# do not execute legacy tests
rm -rf pscript_legacy
'';
meta = with lib; {
description = "Python to JavaScript compiler";
license = licenses.bsd2;
homepage = "https://pscript.readthedocs.io";
maintainers = [ maintainers.matthiasbeyer ];
};
}

View File

@ -0,0 +1,47 @@
{ lib
, python3Packages
, fetchFromGitHub
, pytestCheckHook
, requests
}:
python3Packages.buildPythonPackage rec {
pname = "timetagger";
version = "22.1.2";
src = fetchFromGitHub {
owner = "almarklein";
repo = pname;
rev = "v${version}";
sha256 = "0xrajx0iij7r70ch17m4y6ydyh368dn6nbjsv74pn1x8frd686rw";
};
meta = with lib; {
homepage = "https://timetagger.app";
license = licenses.gpl3;
description = "Tag your time, get the insight";
maintainers = with maintainers; [ matthiasbeyer ];
};
checkInputs = [
pytestCheckHook
requests
];
preCheck = ''
# https://github.com/NixOS/nixpkgs/issues/12591
mkdir -p check-phase
export HOME=$(pwd)/check-phase
'';
propagatedBuildInputs = with python3Packages; [
asgineer
itemdb
jinja2
markdown
pscript
pyjwt
uvicorn
];
}

View File

@ -0,0 +1,39 @@
{ lib
, pkgs
, python3Packages
, fetchFromGitHub
, addr ? "127.0.0.1"
, port ? 8082
}:
#
# Timetagger itself is a library that a user must write a "run.py" script for
# We provide a basic "run.py" script with this package, which simply starts
# timetagger.
#
let
tt = python3Packages.timetagger;
in
python3Packages.buildPythonPackage rec {
pname = tt.name;
version = tt.version;
src = tt.src;
meta = tt.meta;
propagatedBuildInputs = [ tt ]
++ (with python3Packages; [
setuptools
]);
format = "custom";
installPhase = ''
mkdir -p $out/bin
echo "#!${pkgs.python3}/bin/python3" >> $out/bin/timetagger
cat run.py >> $out/bin/timetagger
sed -Ei 's,0\.0\.0\.0:80,${addr}:${toString port},' $out/bin/timetagger
chmod +x $out/bin/timetagger
'';
}

View File

@ -10202,6 +10202,8 @@ with pkgs;
timetrap = callPackage ../applications/office/timetrap { };
timetagger = callPackage ../servers/timetagger { };
timekeeper = callPackage ../applications/office/timekeeper { };
timezonemap = callPackage ../development/libraries/timezonemap { };

View File

@ -634,6 +634,8 @@ in {
asgi-csrf = callPackage ../development/python-modules/asgi-csrf { };
asgineer = callPackage ../development/python-modules/asgineer { };
asgiref = callPackage ../development/python-modules/asgiref { };
asmog = callPackage ../development/python-modules/asmog { };
@ -4055,6 +4057,8 @@ in {
itemadapter = callPackage ../development/python-modules/itemadapter { };
itemdb = callPackage ../development/python-modules/itemdb { };
itemloaders = callPackage ../development/python-modules/itemloaders { };
iterm2 = callPackage ../development/python-modules/iterm2 { };
@ -6332,6 +6336,8 @@ in {
psautohint = callPackage ../development/python-modules/psautohint { };
pscript = callPackage ../development/python-modules/pscript { };
psd-tools = callPackage ../development/python-modules/psd-tools { };
psutil = callPackage ../development/python-modules/psutil { };
@ -9713,6 +9719,8 @@ in {
timeout-decorator = callPackage ../development/python-modules/timeout-decorator { };
timetagger = callPackage ../development/python-modules/timetagger { };
timezonefinder = callPackage ../development/python-modules/timezonefinder { };
tinycss2 = callPackage ../development/python-modules/tinycss2 { };