about summary refs log tree commit diff stats
path: root/modules/by-name/gr/grocy/module.nix
blob: 28107f283cac529414ce31bc6e827fee05c03823 (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
{
  config,
  lib,
  ...
}: let
  cfg = config.vhack.grocy;
  data = "/var/lib/grocy";
in {
  options.vhack.grocy = {
    enable = lib.mkEnableOption "grocy";

    domain = lib.mkOption {
      type = lib.types.str;
      description = "FQDN for the grocy instance.";
    };
  };

  config = lib.mkIf cfg.enable {
    services.grocy = {
      enable = true;

      hostName = cfg.domain;
      dataDir = data;

      settings = {
        currency = "EUR";
        culture = "sv_SE";
        calendar.firstDayOfWeek = 1;
      };
    };

    vhack.persist.directories = [
      {
        directory = data;
        user = "grocy";
        group = "grocy";
        mode = "0700";
      }
    ];

    users = {
      groups.grocy = {
        gid = config.vhack.constants.ids.gids.grocy;
      };
      users.grocy = {
        extraGroups = ["grocy"];
        uid = config.vhack.constants.ids.uids.grocy;
      };
    };
  };
}