mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +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
|
let
|
||||||
inherit (lib) optionals mkOption mkEnableOption types mkIf elem concatStringsSep maintainers;
|
inherit (lib)
|
||||||
|
getOutput
|
||||||
|
maintainers
|
||||||
|
mkEnableOption
|
||||||
|
mkIf
|
||||||
|
mkOption
|
||||||
|
mkPackageOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
cfg = config.networking.stevenblack;
|
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
|
in
|
||||||
{
|
{
|
||||||
options.networking.stevenblack = {
|
options.networking.stevenblack = {
|
||||||
enable = mkEnableOption "the stevenblack hosts file blocklist";
|
enable = mkEnableOption "the stevenblack hosts file blocklist";
|
||||||
|
|
||||||
|
package = mkPackageOption pkgs "stevenblack-blocklist" { };
|
||||||
|
|
||||||
block = mkOption {
|
block = mkOption {
|
||||||
type = types.listOf (types.enum [ "fakenews" "gambling" "porn" "social" ]);
|
type = types.listOf (
|
||||||
|
types.enum [
|
||||||
|
"fakenews"
|
||||||
|
"gambling"
|
||||||
|
"porn"
|
||||||
|
"social"
|
||||||
|
]
|
||||||
|
);
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "Additional blocklist extensions.";
|
description = "Additional blocklist extensions.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
networking.hostFiles = [ ]
|
networking.hostFiles = map (x: "${getOutput x cfg.package}/hosts") ([ "ads" ] ++ cfg.block);
|
||||||
++ optionals (activatedHosts != [ ]) [ hostsPath ]
|
|
||||||
++ optionals (activatedHosts == [ ]) [ "${pkgs.stevenblack-blocklist}/hosts" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
meta.maintainers = [ maintainers.moni maintainers.artturin ];
|
meta.maintainers = with maintainers; [
|
||||||
|
moni
|
||||||
|
artturin
|
||||||
|
frontear
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue