mirror of
https://github.com/StevenBlack/hosts.git
synced 2024-06-30 17:45:52 +02:00
Move and extend NixOS section
This commit is contained in:
parent
3185c957a5
commit
471a2d41dd
|
@ -169,23 +169,6 @@ in hosts format to the generated hosts file.
|
||||||
`--whitelist <whitelistfile>`, or `-w <whitelistfile>`: Use the given whitelist file
|
`--whitelist <whitelistfile>`, or `-w <whitelistfile>`: Use the given whitelist file
|
||||||
to remove hosts from the generated hosts 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?
|
## How do I control which sources are unified?
|
||||||
|
|
||||||
Add one or more *additional* sources, each in a subfolder of the `data/`
|
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
|
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
|
## Updating hosts file on Windows
|
||||||
|
|
||||||
(NOTE: See also some third-party Hosts managers, listed below.)
|
(NOTE: See also some third-party Hosts managers, listed below.)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user