Compare commits
1 commit
55fa0f193a
...
f815391cbc
Author | SHA1 | Date | |
---|---|---|---|
f815391cbc |
1 changed files with 7 additions and 21 deletions
|
@ -6,9 +6,7 @@
|
||||||
inherit (lib) lists mapAttrsToList;
|
inherit (lib) lists mapAttrsToList;
|
||||||
inherit (lib.attrsets) foldAttrs concatMapAttrs;
|
inherit (lib.attrsets) foldAttrs concatMapAttrs;
|
||||||
inherit (lib.asserts) assertMsg;
|
inherit (lib.asserts) assertMsg;
|
||||||
inherit (lib.lists) filter last init;
|
inherit (builtins) elem;
|
||||||
inherit (lib.strings) splitString toInt concatStringsSep;
|
|
||||||
inherit (builtins) elem toString;
|
|
||||||
hostmap = import ./hostmap.nix;
|
hostmap = import ./hostmap.nix;
|
||||||
myhostName = config.networking.hostName;
|
myhostName = config.networking.hostName;
|
||||||
# To turn the hostmap around suitable for networking.hosts the following simple code almost works
|
# To turn the hostmap around suitable for networking.hosts the following simple code almost works
|
||||||
|
@ -21,26 +19,14 @@
|
||||||
if (elem myhostName hosts)
|
if (elem myhostName hosts)
|
||||||
# nixos maps the hostname to the loopback 127.0.0.2 by default, so we exclude it here.
|
# nixos maps the hostname to the loopback 127.0.0.2 by default, so we exclude it here.
|
||||||
# there is also a default localhost to 127.0.0.1 in place
|
# there is also a default localhost to 127.0.0.1 in place
|
||||||
then {"127.0.0.1" = filter (x: x != myhostName) hosts;}
|
then {"127.0.0.1" = lists.filter (x: x != myhostName) hosts;}
|
||||||
else {${ip} = hosts;})
|
else {${ip} = hosts;})
|
||||||
globalhosts;
|
globalhosts;
|
||||||
myIp = assert (assertMsg (hostmap ? ${myhostName}.ipv4) "${myhostName} has no ip configured in nixos/roles/hostmap.nix"); hostmap.${myhostName}.ipv4;
|
myIp = assert (assertMsg (hostmap ? ${myhostName}.ipv4) "${myhostName} has no ip configured in nixos/roles/hostmap.nix"); hostmap.${myhostName}.ipv4;
|
||||||
in {
|
in {
|
||||||
networking = {
|
imports = [
|
||||||
hosts = myhosts;
|
../modules/vmNetwork.nix
|
||||||
interfaces.enX0.ipv4.addresses = [
|
];
|
||||||
{
|
networking.hosts = myhosts;
|
||||||
address = myIp;
|
vmNetwork.ipv4 = myIp;
|
||||||
prefixLength = 16;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
defaultGateway = let
|
|
||||||
addr = splitString "." myIp;
|
|
||||||
addrInit = init addr;
|
|
||||||
addrLastInt = toString (toInt (last addr) + 127);
|
|
||||||
in
|
|
||||||
concatStringsSep "." (addrInit ++ [addrLastInt]);
|
|
||||||
# https://www.hrz.tu-darmstadt.de/services/it_services/nameserver_dns/index.de.jsp
|
|
||||||
nameservers = ["130.83.22.63" "130.83.22.60" "130.83.56.60"];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue