-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodule.nix
64 lines (64 loc) · 1.93 KB
/
module.nix
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
{ finalOverlay }:
{ config, lib, pkgs, ... }: {
options = {
services.mensam = {
enable = lib.mkEnableOption "Mensam.";
environment = lib.mkOption {
default = { };
type = with lib.types; attrsOf string;
description = ''
Environment variables to overwrite the default environment variables.
'';
};
config = lib.mkOption {
default = { };
type = with lib.types; attrsOf anything;
description = ''
Configuration that will be merged with default options and serialized to JSON.
`lib.recursiveUpdate` is used to merge these changes.
'';
};
};
};
config = lib.mkIf config.services.mensam.enable {
environment = {
etc."mensam.json".text = builtins.toJSON (
lib.recursiveUpdate pkgs.mensam.config.default config.services.mensam.config
);
};
nixpkgs.overlays = [
finalOverlay
];
systemd.services.mensam = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
description = "Mensam";
environment = {
MENSAM_CONFIG_FILE = "/etc/mensam.json";
MENSAM_LOG_COLOR = "False";
MENSAM_LOG_FILE = "/var/log/mensam/access.log";
MENSAM_LOG_LEVEL = "LevelInfo";
} // config.services.mensam.environment;
restartTriggers = [
config.environment.etc."mensam.json".source
];
serviceConfig = {
DynamicUser = true;
ExecStart = "${pkgs.mensam.exe}/bin/mensam-server";
LogsDirectory = "mensam";
StateDirectory = "mensam";
};
};
users.users = {
mensam = {
uid = 377;
group = "mensam";
description = "Mensam user";
home = "/var/lib/mensam";
};
};
users.groups = {
mensam.gid = 377;
};
};
}