Skip to content

Commit

Permalink
feat: disable /etc/hosts (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
badele authored Jan 9, 2025
1 parent 5fa5b9e commit 8c7d717
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions nix/nixos/features/commons/networking.nix
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
{ lib, config, ... }:
let
domain = config.homelab.domain;
aliasIps = lib.flatten (
# aliasIps = lib.flatten (lib.mapAttrsToList (name: host:
# let alias = lib.optionals (host.dnsalias != null) host.dnsalias;
# in map (entry: {
# name = entry;
# ip = host.ipv4;
# }) alias) config.homelab.hosts);

lib.mapAttrsToList
(name: host:
let alias = lib.optionals (host.dnsalias != null) host.dnsalias;
in map
(entry: {
name = entry;
ip = host.ipv4;
})
alias)
config.homelab.hosts);
in
{
networking = {
networkmanager.enable = true;

domain = config.homelab.domain;
domain = domain;
enableIPv6 = false;

# add an entry to /etc/hosts for each host
extraHosts = ''
127.0.0.1 cert.adele.im
# ADM
192.168.240.16 traefik.adele.im home.adele.im adguard.adele.im
# Hosts
${lib.concatStringsSep "\n" (lib.mapAttrsToList (hostname: hostinfo:
"${hostinfo.ipv4} ${hostname}.${domain} ${hostname}")
config.homelab.hosts)}
# Alias
${lib.concatMapStringsSep "\n"
(host: "${host.ip} ${host.name}.${domain} ${host.name}") aliasIps}
'';
# extraHosts = ''
# 127.0.0.1 cert.adele.im
#
# # ADM
# 192.168.240.16 traefik.adele.im home.adele.im adguard.adele.im
#
# # Hosts
# ${lib.concatStringsSep "\n" (lib.mapAttrsToList (hostname: hostinfo:
# "${hostinfo.ipv4} ${hostname}.${domain} ${hostname}")
# config.homelab.hosts)}
#
# # Alias
# ${lib.concatMapStringsSep "\n"
# (host: "${host.ip} ${host.name}.${domain} ${host.name}") aliasIps}
# '';

# For ZFS
hostId = "9cd5e8c7";
Expand Down

0 comments on commit 8c7d717

Please sign in to comment.