3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/modules/services/system/nscd.nix
Eelco Dolstra aca8225e3b * Invalidate the nscd hosts cache when an "ip-up" event occurs. This
event is emitted by dhclient and by the network-interfaces job in
  case of statically configured interfaces.  Invalidating the cache is
  necessary to get rid of negative queries.

svn path=/nixos/trunk/; revision=31779
2012-01-21 19:13:43 +00:00

72 lines
1.3 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{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
'';
path = [ pkgs.glibc ];
exec = "nscd -f ${./nscd.conf} -d 2> /dev/null";
};
# Flush nscd's hosts database when the network comes up to get
# rid of any negative entries.
jobs.invalidate_nscd =
{ name = "invalidate-nscd";
description = "Invalidate NSCD cache";
startOn = "ip-up";
task = true;
exec = "${pkgs.glibc}/sbin/nscd --invalidate hosts";
};
};
}