-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2425 from toastal/rm-flake-utils
flake: rm `numtide/flake-utils` dependency
- Loading branch information
Showing
1 changed file
with
46 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,50 @@ | ||
{ | ||
description = "Unified hosts file with base extensions."; | ||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
outputs = { self, nixpkgs, flake-utils }: { | ||
nixosModule = { config, ... }: | ||
with nixpkgs.lib; | ||
let | ||
cfg = config.networking.stevenBlackHosts; | ||
alternatesList = (if cfg.blockFakenews then [ "fakenews" ] else []) ++ | ||
(if cfg.blockGambling then [ "gambling" ] else []) ++ | ||
(if cfg.blockPorn then [ "porn" ] else []) ++ | ||
(if cfg.blockSocial then [ "social" ] else []); | ||
alternatesPath = "alternates/" + builtins.concatStringsSep "-" alternatesList + "/"; | ||
in | ||
{ | ||
options.networking.stevenBlackHosts = { | ||
enable = mkEnableOption "Use Steven Black's hosts file as extra hosts."; | ||
blockFakenews = mkEnableOption "Additionally block fakenews hosts."; | ||
blockGambling = mkEnableOption "Additionally block gambling hosts."; | ||
blockPorn = mkEnableOption "Additionally block porn hosts."; | ||
blockSocial = mkEnableOption "Additionally block social hosts."; | ||
outputs = { self, nixpkgs, ... }@inputs: | ||
let | ||
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.platforms.unix; | ||
|
||
nixpkgsFor = forAllSystems (system: import nixpkgs { | ||
inherit system; | ||
}); | ||
in | ||
{ | ||
nixosModule = { config, ... }: | ||
with nixpkgs.lib; | ||
let | ||
cfg = config.networking.stevenBlackHosts; | ||
alternatesList = (if cfg.blockFakenews then [ "fakenews" ] else []) ++ | ||
(if cfg.blockGambling then [ "gambling" ] else []) ++ | ||
(if cfg.blockPorn then [ "porn" ] else []) ++ | ||
(if cfg.blockSocial then [ "social" ] else []); | ||
alternatesPath = "alternates/" + builtins.concatStringsSep "-" alternatesList + "/"; | ||
in | ||
{ | ||
options.networking.stevenBlackHosts = { | ||
enable = mkEnableOption "Use Steven Black's hosts file as extra hosts."; | ||
blockFakenews = mkEnableOption "Additionally block fakenews hosts."; | ||
blockGambling = mkEnableOption "Additionally block gambling hosts."; | ||
blockPorn = mkEnableOption "Additionally block porn hosts."; | ||
blockSocial = mkEnableOption "Additionally block social hosts."; | ||
}; | ||
config = mkIf cfg.enable { | ||
networking.extraHosts = | ||
builtins.readFile ( | ||
"${self}/" + (if alternatesList != [] then alternatesPath else "") + "hosts" | ||
); | ||
}; | ||
}; | ||
config = mkIf cfg.enable { | ||
networking.extraHosts = | ||
builtins.readFile ( | ||
"${self}/" + (if alternatesList != [] then alternatesPath else "") + "hosts" | ||
); | ||
}; | ||
}; | ||
} // flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
in | ||
{ | ||
devShell = pkgs.mkShell { | ||
buildInputs = with pkgs; [ | ||
python3 | ||
python3Packages.flake8 | ||
python3Packages.requests | ||
]; | ||
}; | ||
} | ||
); | ||
|
||
devShells = forAllSystems (system: | ||
let pkgs = nixpkgsFor.${system}; in | ||
{ | ||
default = pkgs.mkShell { | ||
buildInputs = with pkgs; [ | ||
python3 | ||
python3Packages.flake8 | ||
python3Packages.requests | ||
]; | ||
}; | ||
}); | ||
}; | ||
} |