mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 07:31:20 +00:00
29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
63 lines
1.1 KiB
Nix
63 lines
1.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.haveged;
|
|
|
|
in
|
|
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.haveged = {
|
|
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to enable to haveged entropy daemon, which refills
|
|
/dev/random when low.
|
|
'';
|
|
};
|
|
|
|
refill_threshold = mkOption {
|
|
type = types.int;
|
|
default = 1024;
|
|
description = ''
|
|
The number of bits of available entropy beneath which
|
|
haveged should refill the entropy pool.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.haveged =
|
|
{ description = "Entropy Harvesting Daemon";
|
|
unitConfig.documentation = "man:haveged(8)";
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [ pkgs.haveged ];
|
|
|
|
serviceConfig =
|
|
{ Type = "forking";
|
|
ExecStart = "${pkgs.haveged}/sbin/haveged -w ${toString cfg.refill_threshold} -v 1";
|
|
PIDFile = "/run/haveged.pid";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
} |