mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 04:02:55 +03:00
bf4c0c1900
those are added by mkEnableOption, and .. is replaced to … by markdown processing.
35 lines
1.2 KiB
Nix
35 lines
1.2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) optionals mkOption mkEnableOption types mkIf elem concatStringsSep maintainers mdDoc;
|
|
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 = {
|
|
enable = mkEnableOption (mdDoc "Enable the stevenblack hosts file blocklist");
|
|
|
|
block = mkOption {
|
|
type = types.listOf (types.enum [ "fakenews" "gambling" "porn" "social" ]);
|
|
default = [ ];
|
|
description = mdDoc "Additional blocklist extensions.";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
networking.hostFiles = [ ]
|
|
++ optionals (activatedHosts != [ ]) [ hostsPath ]
|
|
++ optionals (activatedHosts == [ ]) [ "${pkgs.stevenblack-blocklist}/hosts" ];
|
|
};
|
|
|
|
meta.maintainers = [ maintainers.fortuneteller2k maintainers.artturin ];
|
|
}
|