mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
nixos/stevenblack: rework to use distinct package outputs
This commit is contained in:
parent
24e4ca0864
commit
ab98e84e0d
1 changed files with 32 additions and 17 deletions
|
@ -1,34 +1,49 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) optionals mkOption mkEnableOption types mkIf elem concatStringsSep maintainers;
|
||||
inherit (lib)
|
||||
getOutput
|
||||
maintainers
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
mkPackageOption
|
||||
types
|
||||
;
|
||||
|
||||
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";
|
||||
|
||||
package = mkPackageOption pkgs "stevenblack-blocklist" { };
|
||||
|
||||
block = mkOption {
|
||||
type = types.listOf (types.enum [ "fakenews" "gambling" "porn" "social" ]);
|
||||
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" ];
|
||||
networking.hostFiles = map (x: "${getOutput x cfg.package}/hosts") ([ "ads" ] ++ cfg.block);
|
||||
};
|
||||
|
||||
meta.maintainers = [ maintainers.moni maintainers.artturin ];
|
||||
meta.maintainers = with maintainers; [
|
||||
moni
|
||||
artturin
|
||||
frontear
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue