2012-11-22 07:07:25 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
security.rngd.enable = mkOption {
|
2012-11-26 13:45:23 +00:00
|
|
|
default = true;
|
2012-11-22 07:07:25 +00:00
|
|
|
description = ''
|
2012-11-22 09:41:54 +00:00
|
|
|
Whether to enable the rng daemon, which adds entropy from
|
2012-11-22 07:07:25 +00:00
|
|
|
hardware sources of randomness to the kernel entropy pool when
|
2012-11-22 15:14:41 +00:00
|
|
|
available.
|
2012-11-22 07:07:25 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.security.rngd.enable {
|
2012-11-26 13:45:23 +00:00
|
|
|
services.udev.extraRules = ''
|
|
|
|
KERNEL=="random", TAG+="systemd"
|
|
|
|
SUBSYSTEM=="cpu", ENV{MODALIAS}=="x86cpu:*feature:*009E*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"
|
|
|
|
KERNEL=="hw_random", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"
|
|
|
|
KERNEL=="tmp0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"
|
|
|
|
'';
|
|
|
|
|
2012-11-22 07:07:25 +00:00
|
|
|
boot.systemd.services.rngd = {
|
2012-11-26 13:45:23 +00:00
|
|
|
bindsTo = [ "dev-random.device" ];
|
|
|
|
|
|
|
|
after = [ "dev-random.device" ];
|
2012-11-22 07:07:25 +00:00
|
|
|
|
|
|
|
description = "Hardware RNG Entropy Gatherer Daemon";
|
|
|
|
|
|
|
|
serviceConfig.ExecStart = "${pkgs.rng_tools}/sbin/rngd -f";
|
2012-11-26 13:45:23 +00:00
|
|
|
|
|
|
|
restartTriggers = [ pkgs.rng_tools ];
|
2012-11-22 07:07:25 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|