mirror of
https://github.com/StevenBlack/hosts.git
synced 2024-07-02 02:25:54 +02:00
Add Nix Flake
This commit is contained in:
parent
a3bdc8b71b
commit
3185c957a5
40
flake.lock
Normal file
40
flake.lock
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1631561581,
|
||||
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1633267966,
|
||||
"narHash": "sha256-gFKvZ5AmV/dDTKXVxacPbXe4R0BsFpwtVaQxuIm2nnk=",
|
||||
"path": "/nix/store/k13ripsl4n2p6wf2ksy5m017ryykx4qc-source",
|
||||
"rev": "7daf35532d2d8bf5e6f7f962e6cd13a66d01a71d",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
45
flake.nix
Normal file
45
flake.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
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.";
|
||||
};
|
||||
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
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user