Move and extend NixOS section
authorDenis Lehmann <redacted>
Tue, 5 Oct 2021 21:37:29 +0000 (23:37 +0200)
committerDenis Lehmann <redacted>
Tue, 5 Oct 2021 21:37:29 +0000 (23:37 +0200)
readme_template.md

index 138f1eda0fbb5ad8b507b6acf96bf78c34da4631..92a846fe173953e15554981dbb7a0ccb64f6625c 100644 (file)
@@ -169,23 +169,6 @@ in hosts format to the generated hosts file.
 `--whitelist <whitelistfile>`, or `-w <whitelistfile>`: Use the given whitelist file
 to remove hosts from the generated hosts file.
 
-#### Using NixOS
-
-To install hosts file on your machine add the following into your `configuration.nix`:
-
-```nix
-{
-  networking.extraHosts = let
-    hostsPath = https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts;
-    hostsFile = builtins.fetchurl hostsPath;
-  in builtins.readFile "${hostsFile}";
-}
-```
-
-* NOTE: Change `hostsPath` if you need other versions of hosts file.
-* NOTE: The call to `fetchurl` is impure.
-Use `fetchFromGitHub` with the exact commit if you want to always get the same result.
-
 ## How do I control which sources are unified?
 
 Add one or more *additional* sources, each in a subfolder of the `data/`
@@ -297,6 +280,58 @@ editor.
 
 Gentoo users may find [`sb-hosts`](https://github.com/PF4Public/gentoo-overlay/tree/master/net-misc/sb-hosts) in [::pf4public](https://github.com/PF4Public/gentoo-overlay) Gentoo overlay
 
+## NixOS
+
+To install hosts file on your machine add the following into your `configuration.nix`:
+
+```nix
+{
+  networking.extraHosts = let
+    hostsPath = https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts;
+    hostsFile = builtins.fetchurl hostsPath;
+  in builtins.readFile "${hostsFile}";
+}
+```
+
+* NOTE: Change `hostsPath` if you need other versions of hosts file.
+* NOTE: The call to `fetchurl` is impure.
+Use `fetchFromGitHub` with the exact commit if you want to always get the same result.
+
+### Nix Flake
+
+NixOS installations which are managed through *flakes* can use the hosts file like this:
+
+```nix
+{
+  inputs.hosts.url = github:StevenBlack/hosts;
+  outputs = { self, nixpkgs, hosts }: {
+    nixosConfigurations.my-hostname = {
+      system = "<architecture>";
+      modules = [
+
+        hosts.nixosModule {
+          networking.stevenBlackHosts.enable = true;
+        }
+
+      ];
+    };
+  };
+}
+```
+
+The hosts extensions are also available with the following options:
+
+```nix
+{
+  networking.stevenBlackHosts = {
+    blockFakenews = true;
+    blockGambling = true;
+    blockPorn = true;
+    blockSocial = true;
+  };
+}
+```
+
 ## Updating hosts file on Windows
 
 (NOTE: See also some third-party Hosts managers, listed below.)
git clone https://git.99rst.org/PROJECT