grafana-alloy: don't build the frontend twice
[NixPkgs.git] / nixos / modules / services / security / haveged.nix
blob4c686d74268af060b0927a1afa17ebca2fae0ad9
1 { config, lib, pkgs, ... }:
3 with lib;
5 let
6   cfg = config.services.haveged;
8 in
12   ###### interface
14   options = {
16     services.haveged = {
18       enable = mkEnableOption ''
19         haveged entropy daemon, which refills /dev/random when low.
20         NOTE: does nothing on kernels newer than 5.6
21       '';
22       # source for the note https://github.com/jirka-h/haveged/issues/57
24       refill_threshold = mkOption {
25         type = types.int;
26         default = 1024;
27         description = ''
28           The number of bits of available entropy beneath which
29           haveged should refill the entropy pool.
30         '';
31       };
33     };
35   };
37   config = mkIf cfg.enable {
39     # https://github.com/jirka-h/haveged/blob/a4b69d65a8dfc5a9f52ff8505c7f58dcf8b9234f/contrib/Fedora/haveged.service
40     systemd.services.haveged = {
41       description = "Entropy Daemon based on the HAVEGE algorithm";
42       unitConfig = {
43         Documentation = "man:haveged(8)";
44         DefaultDependencies = false;
45         ConditionKernelVersion = "<5.6";
46       };
47       wantedBy = [ "sysinit.target" ];
48       after = [ "systemd-tmpfiles-setup-dev.service" ];
49       before = [ "sysinit.target" "shutdown.target" "systemd-journald.service" ];
51       serviceConfig = {
52         ExecStart = "${pkgs.haveged}/bin/haveged -w ${toString cfg.refill_threshold} --Foreground -v 1";
53         Restart = "always";
54         SuccessExitStatus = "137 143";
55         SecureBits = "noroot-locked";
56         CapabilityBoundingSet = [ "CAP_SYS_ADMIN" "CAP_SYS_CHROOT" ];
57         # We can *not* set PrivateTmp=true as it can cause an ordering cycle.
58         PrivateTmp = false;
59         PrivateDevices = true;
60         ProtectSystem = "full";
61         ProtectHome = true;
62         ProtectHostname = true;
63         ProtectKernelLogs = true;
64         ProtectKernelModules = true;
65         RestrictNamespaces = true;
66         RestrictRealtime = true;
67         LockPersonality = true;
68         MemoryDenyWriteExecute = true;
69         SystemCallArchitectures = "native";
70         SystemCallFilter = [ "@system-service" "newuname" "~@mount" ];
71         SystemCallErrorNumber = "EPERM";
72       };
74     };
75   };