3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #169694 from fortuneteller2k/stevenblock-module

This commit is contained in:
Artturi 2023-01-10 19:26:24 +02:00 committed by GitHub
commit a08b0ed485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 0 deletions

View file

@ -60,6 +60,14 @@
<link linkend="opt-programs.fzf.fuzzyCompletion">programs.fzf</link>.
</para>
</listitem>
<listitem>
<para>
<link xlink:href="https://github.com/StevenBlack/hosts">stevenblack-blocklist</link>,
A unified hosts file with base extensions for blocking
unwanted websites. Available as
<link xlink:href="options.html#opt-networking.stevenblack.enable">networking.stevenblack</link>.
</para>
</listitem>
<listitem>
<para>
<link xlink:href="https://github.com/ellie/atuin">atuin</link>,

View file

@ -24,6 +24,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.fuzzyCompletion).
- [stevenblack-blocklist](https://github.com/StevenBlack/hosts), A unified hosts file with base extensions for blocking unwanted websites. Available as [networking.stevenblack](options.html#opt-networking.stevenblack.enable).
- [atuin](https://github.com/ellie/atuin), a sync server for shell history. Available as [services.atuin](#opt-services.atuin.enable).
- [mmsd](https://gitlab.com/kop316/mmsd), a lower level daemon that transmits and recieves MMSes. Available as [services.mmsd](#opt-services.mmsd.enable).

View file

@ -0,0 +1,34 @@
{ 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 ];
}

View file

@ -23,6 +23,7 @@
./config/qt.nix
./config/resolvconf.nix
./config/shells-environment.nix
./config/stevenblack.nix
./config/swap.nix
./config/sysctl.nix
./config/system-environment.nix