diff options
author | Marijan Petričević <marijan.petricevic94@gmail.com> | 2020-01-20 12:34:57 +0100 |
---|---|---|
committer | Marijan Petričević <marijan.petricevic94@gmail.com> | 2021-01-28 15:29:53 +0100 |
commit | f56089ded5e3895d9fbd82bfbdff79b761e42118 (patch) | |
tree | 41b783450a844d710b814bc9693ab2a70950c933 /nixos/modules/services/web-apps/hledger-web.nix | |
parent | d439e559ef6692a0ef37c8f6f3341476ce529bb8 (diff) | |
download | nixlib-f56089ded5e3895d9fbd82bfbdff79b761e42118.tar nixlib-f56089ded5e3895d9fbd82bfbdff79b761e42118.tar.gz nixlib-f56089ded5e3895d9fbd82bfbdff79b761e42118.tar.bz2 nixlib-f56089ded5e3895d9fbd82bfbdff79b761e42118.tar.lz nixlib-f56089ded5e3895d9fbd82bfbdff79b761e42118.tar.xz nixlib-f56089ded5e3895d9fbd82bfbdff79b761e42118.tar.zst nixlib-f56089ded5e3895d9fbd82bfbdff79b761e42118.zip |
nixos/hledger-web: init module and test
Diffstat (limited to 'nixos/modules/services/web-apps/hledger-web.nix')
-rw-r--r-- | nixos/modules/services/web-apps/hledger-web.nix | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/nixos/modules/services/web-apps/hledger-web.nix b/nixos/modules/services/web-apps/hledger-web.nix new file mode 100644 index 000000000000..43fc4daa177f --- /dev/null +++ b/nixos/modules/services/web-apps/hledger-web.nix @@ -0,0 +1,77 @@ +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.services.hledger-web; +in { + options.services.hledger-web = { + + enable = mkEnableOption "hledger-web service"; + + serveApi = mkEnableOption "Serve only the JSON web API, without the web UI."; + + host = mkOption { + type = types.str; + default = "127.0.0.1"; + description = '' + Address to listen on. + ''; + }; + + port = mkOption { + type = types.port; + default = 5000; + example = "80"; + description = '' + Port to listen on. + ''; + }; + + capabilities = mkOption { + type = types.commas; + default = "view"; + description = '' + Enable the view, add, and/or manage capabilities. E.g. view,add + ''; + }; + + journalFile = mkOption { + type = types.path; + example = "/home/hledger/.hledger.journal"; + description = '' + Input journal file. + ''; + }; + + baseUrl = mkOption { + type = with types; nullOr str; + default = null; + example = "https://example.org"; + description = '' + Base URL, when sharing over a network. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.services.hledger-web = { + description = "hledger-web - web-app for the hledger accounting tool."; + documentation = [ https://hledger.org/hledger-web.html ]; + wantedBy = [ "multi-user.target" ]; + after = [ "networking.target" ]; + serviceConfig = { + ExecStart = '' + ${pkgs.hledger-web}/bin/hledger-web \ + --host=${cfg.host} \ + --port=${toString cfg.port} \ + --file=${cfg.journalFile} \ + "--capabilities=${cfg.capabilities}" \ + ${optionalString (cfg.baseUrl != null) "--base-url=${cfg.baseUrl}"} \ + ${optionalString (cfg.serveApi) "--serve-api"} + ''; + Restart = "always"; + }; + }; + }; + + meta.maintainers = with lib.maintainers; [ marijanp ]; +} |