diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-12-20 18:37:01 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2022-01-15 09:07:52 +0100 |
commit | f3eaf668820a41ec78a6b6d8aedb078b4a87372e (patch) | |
tree | bae851efe0addc16407565b9c9e3638d5d151d91 /nixos/modules/services/web-apps/timetagger.nix | |
parent | a2a43df955355e4679acc04dc71a7c737950dd60 (diff) | |
download | nixpkgs-f3eaf668820a41ec78a6b6d8aedb078b4a87372e.tar nixpkgs-f3eaf668820a41ec78a6b6d8aedb078b4a87372e.tar.gz nixpkgs-f3eaf668820a41ec78a6b6d8aedb078b4a87372e.tar.bz2 nixpkgs-f3eaf668820a41ec78a6b6d8aedb078b4a87372e.tar.lz nixpkgs-f3eaf668820a41ec78a6b6d8aedb078b4a87372e.tar.xz nixpkgs-f3eaf668820a41ec78a6b6d8aedb078b4a87372e.tar.zst nixpkgs-f3eaf668820a41ec78a6b6d8aedb078b4a87372e.zip |
Add service module for timetagger
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'nixos/modules/services/web-apps/timetagger.nix')
-rw-r--r-- | nixos/modules/services/web-apps/timetagger.nix | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/nixos/modules/services/web-apps/timetagger.nix b/nixos/modules/services/web-apps/timetagger.nix new file mode 100644 index 00000000000..9dad949b093 --- /dev/null +++ b/nixos/modules/services/web-apps/timetagger.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkEnableOption mkIf mkOption types literalExpression; + + cfg = config.services.timetagger; +in { + + options = { + services.timetagger = { + enable = mkEnableOption '' + 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 = null; + type = types.package; + }; + }; + }; + + config = let + timetaggerPkg = if !isNull cfg.package then cfg.package else + pkgs.timetagger.overwriteAttrs { + addr = cfg.bindAddr; + port = cfg.port; + }; + + in mkIf cfg.enable { + systemd.services.timetagger = { + description = "Timetagger service"; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + User = "timetagger"; + Group = "timetagger"; + StateDirectory = "timetagger"; + + ExecStart = "${timetaggerPkg}/bin/timetagger"; + + Restart = "on-failure"; + RestartSec = 1; + }; + }; + }; +} + |