summary refs log tree commit diff
path: root/modules/services/system/nscd.nix
blob: ede6c4213dbc23d10464e6b69c906f48b9611ea0 (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
{pkgs, config, ...}:

with pkgs.lib;

let

  nssModulesPath = config.system.nssModules.path;

  inherit (pkgs.lib) singleton;
  
in

{

  ###### interface

  options = {

    services.nscd = {

      enable = mkOption {
        default = true;
        description = "
          Whether to enable the Name Service Cache Daemon.
        ";
      };

    };

  };

  ###### implementation

  config = mkIf config.services.nscd.enable {
  
    users.extraUsers = singleton
      { name = "nscd";
        uid = config.ids.uids.nscd;
        description = "Name service cache daemon user";
      };

    jobs.nscd =
      { description = "Name Service Cache Daemon";

        startOn = "startup";

        environment = { LD_LIBRARY_PATH = nssModulesPath; };
        
        preStart =
          ''
            mkdir -m 0755 -p /var/run/nscd
            mkdir -m 0755 -p /var/db/nscd
          '';

        exec = "${pkgs.glibc}/sbin/nscd -f ${./nscd.conf} -d 2> /dev/null";
      };

  };
}