mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 17:33:09 +00:00
6afb255d97
these changes were generated with nixq 0.0.2, by running nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix two mentions of the mdDoc function remain in nixos/, both of which are inside of comments. Since lib.mdDoc is already defined as just id, this commit is a no-op as far as Nix (and the built manual) is concerned.
35 lines
1.1 KiB
Nix
35 lines
1.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) optionals mkOption mkEnableOption types mkIf elem concatStringsSep maintainers;
|
|
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 "the stevenblack hosts file blocklist";
|
|
|
|
block = mkOption {
|
|
type = types.listOf (types.enum [ "fakenews" "gambling" "porn" "social" ]);
|
|
default = [ ];
|
|
description = "Additional blocklist extensions.";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
networking.hostFiles = [ ]
|
|
++ optionals (activatedHosts != [ ]) [ hostsPath ]
|
|
++ optionals (activatedHosts == [ ]) [ "${pkgs.stevenblack-blocklist}/hosts" ];
|
|
};
|
|
|
|
meta.maintainers = [ maintainers.moni maintainers.artturin ];
|
|
}
|