1# Fusion Inventory daemon.
2{
3 config,
4 lib,
5 pkgs,
6 ...
7}:
8let
9 cfg = config.services.fusionInventory;
10
11 configFile = pkgs.writeText "fusion_inventory.conf" ''
12 server = ${lib.concatStringsSep ", " cfg.servers}
13
14 logger = stderr
15
16 ${cfg.extraConfig}
17 '';
18
19in
20{
21
22 ###### interface
23
24 options = {
25
26 services.fusionInventory = {
27
28 enable = lib.mkEnableOption "Fusion Inventory Agent";
29
30 servers = lib.mkOption {
31 type = lib.types.listOf lib.types.str;
32 description = ''
33 The urls of the OCS/GLPI servers to connect to.
34 '';
35 };
36
37 extraConfig = lib.mkOption {
38 default = "";
39 type = lib.types.lines;
40 description = ''
41 Configuration that is injected verbatim into the configuration file.
42 '';
43 };
44 };
45 };
46
47 ###### implementation
48
49 config = lib.mkIf cfg.enable {
50
51 users.users.fusion-inventory = {
52 description = "FusionInventory user";
53 isSystemUser = true;
54 };
55
56 systemd.services.fusion-inventory = {
57 description = "Fusion Inventory Agent";
58 wantedBy = [ "multi-user.target" ];
59
60 serviceConfig = {
61 ExecStart = "${pkgs.fusionInventory}/bin/fusioninventory-agent --conf-file=${configFile} --daemon --no-fork";
62 };
63 };
64 };
65}