dns
This commit is contained in:
parent
1f65e12585
commit
7584ff9a39
5 changed files with 49 additions and 48 deletions
|
|
@ -26,9 +26,9 @@
|
|||
lib = nixpkgs.lib;
|
||||
lib' = import ./lib.nix { inherit lib; };
|
||||
|
||||
specialArgs = {
|
||||
specialArgs = rec {
|
||||
inherit inputs lib';
|
||||
var = (lib'.walk-dir ./var).map_import_with_lib;
|
||||
var = (lib'.walk-dir ./var)._map (f: import f { inherit lib var; });
|
||||
};
|
||||
overlays = _: {
|
||||
nixpkgs.overlays = [ colmena.overlay ];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ ... }:
|
||||
{ var, ... }:
|
||||
{
|
||||
imports = [
|
||||
./boot.nix
|
||||
|
|
@ -7,4 +7,6 @@
|
|||
./shell.nix
|
||||
./users.nix
|
||||
];
|
||||
|
||||
networking.extraHosts = var.lan-dns.hostsFile;
|
||||
}
|
||||
|
|
|
|||
32
lib.nix
32
lib.nix
|
|
@ -1,14 +1,10 @@
|
|||
{ lib, ... }:
|
||||
with builtins;
|
||||
let
|
||||
lib' = rec {
|
||||
walk-dir =
|
||||
let
|
||||
walk-dir-inner =
|
||||
path:
|
||||
let
|
||||
dir = readDir path;
|
||||
|
||||
in
|
||||
lib.mapAttrs' (filename: value: {
|
||||
name = lib.removeSuffix ".nix" filename;
|
||||
|
|
@ -21,31 +17,13 @@ let
|
|||
throw "Items of type ${value} are unsupported.";
|
||||
}) dir;
|
||||
|
||||
helper-attrs =
|
||||
subpaths:
|
||||
let
|
||||
_files = lib.collect (x: isPath x || isString x) subpaths;
|
||||
_nix_files = filter (lib.hasSuffix ".nix") _files;
|
||||
in
|
||||
rec {
|
||||
to_mod = _: {
|
||||
imports = _nix_files;
|
||||
};
|
||||
to_mod_without_default = without_default.to_mod;
|
||||
collect_nix_files = _nix_files;
|
||||
map_import = lib.mapAttrsRecursive (_: import) subpaths;
|
||||
map_import_with_lib = lib.mapAttrsRecursive (_: x: (import x) { inherit lib lib'; }) subpaths;
|
||||
without_default =
|
||||
let
|
||||
subpaths' = removeAttrs subpaths [ "default" ];
|
||||
in
|
||||
with-helper-attrs subpaths';
|
||||
helper-attrs = subpaths: {
|
||||
_map = f: lib.mapAttrsRecursive (_: f) subpaths;
|
||||
};
|
||||
|
||||
with-helper-attrs =
|
||||
x: if isAttrs x then lib.mapAttrs (_: with-helper-attrs) x // helper-attrs x else x;
|
||||
in
|
||||
p: with-helper-attrs (walk-dir-inner p);
|
||||
};
|
||||
in
|
||||
lib'
|
||||
{
|
||||
walk-dir = p: with-helper-attrs (walk-dir-inner p);
|
||||
}
|
||||
|
|
|
|||
18
var/lan-dns.nix
Normal file
18
var/lan-dns.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{ lib, var, ... }:
|
||||
let
|
||||
lan-tld = ".lan";
|
||||
lan-base-domain = ".hdohmen.de";
|
||||
lan-hosts = lib.mapAttrs' (name: value: {
|
||||
name = "${name}${lan-tld}";
|
||||
inherit value;
|
||||
}) var.wg.ips;
|
||||
in
|
||||
rec {
|
||||
hostsFile = lib.concatStringsSep "\n" (lib.mapAttrsFlatten (n: v: "${n}\t${v}") hosts);
|
||||
hosts =
|
||||
lan-hosts
|
||||
// lib.mapAttrs' (name: value: {
|
||||
name = "${name}${lan-base-domain}";
|
||||
inherit value;
|
||||
}) lan-hosts;
|
||||
}
|
||||
|
|
@ -32,4 +32,7 @@ rec {
|
|||
lib.attrValues (lib.filterAttrs (n: _: n != host) wireguard-network)
|
||||
);
|
||||
|
||||
ips =
|
||||
with builtins;
|
||||
mapAttrs (name: value: head (lib.splitString "/" (head value.ips))) wireguard-network;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue