Merge pull request #2813 from toastal/nix-flake-avoid-with-lib
authorSteven Black <redacted>
Tue, 24 Feb 2026 16:43:56 +0000 (11:43 -0500)
committerGitHub <redacted>
Tue, 24 Feb 2026 16:43:56 +0000 (11:43 -0500)
nix flake refactor: avoid `with lib;` & use `lib.optional*`

1  2 
flake.nix

diff --cc flake.nix
index 0cff5be403fcba579920c0edf6204b89406170ae,17dee810cbfc66c47d86bb14d9ea6101e93ffba8..34804aa37e58f920f82aa9b8a4f786764075f49d
+++ b/flake.nix
          in
          {
            options.networking.stevenBlackHosts = {
-             enable = mkEnableOption "Steven Black's hosts file";
-             enableIPv6 = mkEnableOption "IPv6 rules" // {
+             enable = lib.mkEnableOption "Steven Black's hosts file";
+             enableIPv6 = lib.mkEnableOption "IPv6 rules" // {
                default = config.networking.enableIPv6;
 +              defaultText = literalExpression "config.networking.enableIPv6";
              };
-             blockFakenews = mkEnableOption "fakenews hosts entries";
-             blockGambling = mkEnableOption "gambling hosts entries";
-             blockPorn = mkEnableOption "porn hosts entries";
-             blockSocial = mkEnableOption "social hosts entries";
+             blockFakenews = lib.mkEnableOption "fakenews hosts entries";
+             blockGambling = lib.mkEnableOption "gambling hosts entries";
+             blockPorn = lib.mkEnableOption "porn hosts entries";
+             blockSocial = lib.mkEnableOption "social hosts entries";
            };
-           config = mkIf cfg.enable {
+           config = lib.mkIf cfg.enable {
              networking.extraHosts =
                let
-                 orig = builtins.readFile ("${self}/" + (if alternatesList != [] then alternatesPath else "") + "hosts");
+                 orig = builtins.readFile ("${self}/" + (lib.optionalString (alternatesList != []) alternatesPath) + "hosts");
                  ipv6 = builtins.replaceStrings [ "0.0.0.0" ] [ "::" ] orig;
-               in orig + (optionalString cfg.enableIPv6 ("\n" + ipv6));
+               in
+               orig + (lib.optionalString cfg.enableIPv6 ("\n" + ipv6));
            };
          };
  
git clone https://git.99rst.org/PROJECT