Compare commits
1 commit
e42e9f0ff7
...
55fa0f193a
Author | SHA1 | Date | |
---|---|---|---|
55fa0f193a |
1 changed files with 48 additions and 0 deletions
48
nixos/modules/vmNetwork.nix
Normal file
48
nixos/modules/vmNetwork.nix
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit
|
||||||
|
(lib)
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
last
|
||||||
|
init
|
||||||
|
;
|
||||||
|
inherit
|
||||||
|
(lib.strings)
|
||||||
|
splitString
|
||||||
|
concatStringsSep
|
||||||
|
toInt
|
||||||
|
;
|
||||||
|
cfg = config.vmNetwork;
|
||||||
|
in {
|
||||||
|
imports = [];
|
||||||
|
|
||||||
|
options.vmNetwork = {
|
||||||
|
ipv4 = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "the ipv4 adress of this machine";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
networking = {
|
||||||
|
interfaces.enX0.ipv4.addresses = [
|
||||||
|
{
|
||||||
|
address = cfg.ipv4;
|
||||||
|
prefixLength = 16;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
defaultGateway = let
|
||||||
|
addr = splitString "." cfg.ipv4;
|
||||||
|
addrInit = init addr;
|
||||||
|
addrLastInt = builtins.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