nixpkgs/nixos/modules/security/rngd.nix

36 lines
924 B
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
{
options = {
security.rngd.enable = mkOption {
2013-10-30 17:37:45 +01:00
type = types.bool;
default = true;
description = ''
2012-11-22 10:41:54 +01:00
Whether to enable the rng daemon, which adds entropy from
hardware sources of randomness to the kernel entropy pool when
available.
'';
};
};
config = mkIf config.security.rngd.enable {
services.udev.extraRules = ''
KERNEL=="random", TAG+="systemd"
SUBSYSTEM=="cpu", ENV{MODALIAS}=="cpu:type:x86,*feature:*009E*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"
KERNEL=="hw_random", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"
'';
systemd.services.rngd = {
bindsTo = [ "dev-random.device" ];
after = [ "dev-random.device" ];
description = "Hardware RNG Entropy Gatherer Daemon";
2018-11-05 10:41:38 +01:00
serviceConfig.ExecStart = "${pkgs.rng-tools}/sbin/rngd -f";
};
};
}