blob: 43fc4daa177fecf6853926ec2c0df07b6ad7c726 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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 ];
}
|