2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2014-01-17 10:02:13 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2014-01-17 10:02:13 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.haveged;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.haveged = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
2020-08-07 15:43:58 +02:00
|
|
|
Whether to enable to haveged entropy daemon, which refills
|
2014-01-17 10:02:13 +01:00
|
|
|
/dev/random when low.
|
|
|
|
'';
|
|
|
|
};
|
2020-08-07 15:43:58 +02:00
|
|
|
|
2014-01-17 10:02:13 +01:00
|
|
|
refill_threshold = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 1024;
|
|
|
|
description = ''
|
|
|
|
The number of bits of available entropy beneath which
|
|
|
|
haveged should refill the entropy pool.
|
|
|
|
'';
|
|
|
|
};
|
2020-08-07 15:43:58 +02:00
|
|
|
|
2014-01-17 10:02:13 +01:00
|
|
|
};
|
2020-08-07 15:43:58 +02:00
|
|
|
|
2014-01-17 10:02:13 +01:00
|
|
|
};
|
2020-08-07 15:43:58 +02:00
|
|
|
|
|
|
|
|
2014-01-17 10:02:13 +01:00
|
|
|
###### implementation
|
2020-08-07 15:43:58 +02:00
|
|
|
|
2014-01-17 10:02:13 +01:00
|
|
|
config = mkIf cfg.enable {
|
2020-08-07 15:43:58 +02:00
|
|
|
|
2014-01-17 10:02:13 +01:00
|
|
|
systemd.services.haveged =
|
|
|
|
{ description = "Entropy Harvesting Daemon";
|
2014-11-19 12:56:32 +01:00
|
|
|
unitConfig.Documentation = "man:haveged(8)";
|
2014-01-17 10:02:13 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-09-13 07:07:46 +02:00
|
|
|
|
2014-01-17 10:02:13 +01:00
|
|
|
path = [ pkgs.haveged ];
|
2016-09-13 07:07:46 +02:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.haveged}/bin/haveged -F -w ${toString cfg.refill_threshold} -v 1";
|
|
|
|
SuccessExitStatus = 143;
|
|
|
|
PrivateTmp = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateNetwork = true;
|
|
|
|
ProtectSystem = "full";
|
|
|
|
ProtectHome = true;
|
|
|
|
};
|
2014-01-17 10:02:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2020-08-07 15:43:58 +02:00
|
|
|
|
2014-11-19 12:56:32 +01:00
|
|
|
}
|