2023-01-11 07:51:40 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2024-04-21 15:54:59 +00:00
|
|
|
inherit (lib) optionals mkOption mkEnableOption types mkIf elem concatStringsSep maintainers;
|
2023-01-11 07:51:40 +00:00
|
|
|
cfg = config.networking.stevenblack;
|
|
|
|
|
|
|
|
# needs to be in a specific order
|
|
|
|
activatedHosts = with cfg; [ ]
|
|
|
|
++ optionals (elem "fakenews" block) [ "fakenews" ]
|
|
|
|
++ optionals (elem "gambling" block) [ "gambling" ]
|
|
|
|
++ optionals (elem "porn" block) [ "porn" ]
|
|
|
|
++ optionals (elem "social" block) [ "social" ];
|
|
|
|
|
|
|
|
hostsPath = "${pkgs.stevenblack-blocklist}/alternates/" + concatStringsSep "-" activatedHosts + "/hosts";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.networking.stevenblack = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "the stevenblack hosts file blocklist";
|
2023-01-11 07:51:40 +00:00
|
|
|
|
|
|
|
block = mkOption {
|
|
|
|
type = types.listOf (types.enum [ "fakenews" "gambling" "porn" "social" ]);
|
|
|
|
default = [ ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Additional blocklist extensions.";
|
2023-01-11 07:51:40 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
networking.hostFiles = [ ]
|
|
|
|
++ optionals (activatedHosts != [ ]) [ hostsPath ]
|
|
|
|
++ optionals (activatedHosts == [ ]) [ "${pkgs.stevenblack-blocklist}/hosts" ];
|
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
meta.maintainers = [ maintainers.moni maintainers.artturin ];
|
2023-01-11 07:51:40 +00:00
|
|
|
}
|