nixos/services.infnoise: remove with lib;

This commit is contained in:
Felix Buehler 2024-12-29 21:50:37 +01:00
parent 3bb7989e0d
commit bd92ad1747

View File

@ -4,38 +4,35 @@
pkgs, pkgs,
... ...
}: }:
with lib;
let let
cfg = config.services.infnoise; cfg = config.services.infnoise;
in in
{ {
options = { options = {
services.infnoise = { services.infnoise = {
enable = mkEnableOption "the Infinite Noise TRNG driver"; enable = lib.mkEnableOption "the Infinite Noise TRNG driver";
fillDevRandom = mkOption { fillDevRandom = lib.mkOption {
description = '' description = ''
Whether to run the infnoise driver as a daemon to refill /dev/random. Whether to run the infnoise driver as a daemon to refill /dev/random.
If disabled, you can use the `infnoise` command-line tool to If disabled, you can use the `infnoise` command-line tool to
manually obtain randomness. manually obtain randomness.
''; '';
type = types.bool; type = lib.types.bool;
default = true; default = true;
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.infnoise ]; environment.systemPackages = [ pkgs.infnoise ];
services.udev.extraRules = '' services.udev.extraRules = ''
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", SYMLINK+="infnoise", TAG+="systemd", GROUP="dialout", MODE="0664", ENV{SYSTEMD_WANTS}="infnoise.service" SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", SYMLINK+="infnoise", TAG+="systemd", GROUP="dialout", MODE="0664", ENV{SYSTEMD_WANTS}="infnoise.service"
''; '';
systemd.services.infnoise = mkIf cfg.fillDevRandom { systemd.services.infnoise = lib.mkIf cfg.fillDevRandom {
description = "Infinite Noise TRNG driver"; description = "Infinite Noise TRNG driver";
bindsTo = [ "dev-infnoise.device" ]; bindsTo = [ "dev-infnoise.device" ];