| 
									
										
										
										
											2014-04-14 16:26:48 +02:00
										 |  |  | { config, lib, pkgs, ... }: | 
					
						
							| 
									
										
										
										
											2012-11-22 02:07:25 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-14 16:26:48 +02:00
										 |  |  | with lib; | 
					
						
							| 
									
										
										
										
											2012-11-22 02:07:25 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   options = { | 
					
						
							|  |  |  |     security.rngd.enable = mkOption { | 
					
						
							| 
									
										
										
										
											2013-10-30 17:37:45 +01:00
										 |  |  |       type = types.bool; | 
					
						
							| 
									
										
										
										
											2012-11-26 08:45:23 -05:00
										 |  |  |       default = true; | 
					
						
							| 
									
										
										
										
											2012-11-22 02:07:25 -05:00
										 |  |  |       description = ''
 | 
					
						
							| 
									
										
										
										
											2012-11-22 10:41:54 +01:00
										 |  |  |         Whether to enable the rng daemon, which adds entropy from | 
					
						
							| 
									
										
										
										
											2012-11-22 02:07:25 -05:00
										 |  |  |         hardware sources of randomness to the kernel entropy pool when | 
					
						
							| 
									
										
										
										
											2012-11-22 10:14:41 -05:00
										 |  |  |         available. | 
					
						
							| 
									
										
										
										
											2012-11-22 02:07:25 -05:00
										 |  |  |       '';
 | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   config = mkIf config.security.rngd.enable { | 
					
						
							| 
									
										
										
										
											2012-11-26 08:45:23 -05: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" | 
					
						
							|  |  |  |     '';
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-16 12:33:18 +01:00
										 |  |  |     systemd.services.rngd = { | 
					
						
							| 
									
										
										
										
											2012-11-26 08:45:23 -05:00
										 |  |  |       bindsTo = [ "dev-random.device" ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       after = [ "dev-random.device" ]; | 
					
						
							| 
									
										
										
										
											2012-11-22 02:07:25 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       description = "Hardware RNG Entropy Gatherer Daemon"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-22 13:41:22 +02:00
										 |  |  |       serviceConfig.ExecStart = "${pkgs.rng_tools}/sbin/rngd -f -v" + | 
					
						
							|  |  |  |         (if config.services.tcsd.enable then " --no-tpm=1" else ""); | 
					
						
							| 
									
										
										
										
											2012-11-26 08:45:23 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       restartTriggers = [ pkgs.rng_tools ]; | 
					
						
							| 
									
										
										
										
											2012-11-22 02:07:25 -05:00
										 |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |