forked from Fachschaft/nixConfig
Compare commits
No commits in common. "79c731ccd3b6b3171da9979c90dcd72e541bb3e8" and "1a819e1ca4c5214c210bc21095d5d5644cdea514" have entirely different histories.
79c731ccd3
...
1a819e1ca4
10 changed files with 58 additions and 106 deletions
|
@ -4,6 +4,7 @@
|
||||||
../../modules/jitsi.nix
|
../../modules/jitsi.nix
|
||||||
../../roles
|
../../roles
|
||||||
../../roles/vm.nix
|
../../roles/vm.nix
|
||||||
|
../../modules/vmNetwork.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
services.mathebau-jitsi = {
|
services.mathebau-jitsi = {
|
||||||
|
@ -13,5 +14,6 @@
|
||||||
|
|
||||||
# System configuration here
|
# System configuration here
|
||||||
networking.hostName = "ghatanothoa";
|
networking.hostName = "ghatanothoa";
|
||||||
|
vmNetwork.ipv4 = "192.168.0.25";
|
||||||
system.stateVersion = "23.11";
|
system.stateVersion = "23.11";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
../../modules/mailman.nix
|
../../modules/mailman.nix
|
||||||
../../roles
|
../../roles
|
||||||
../../roles/vm.nix
|
../../roles/vm.nix
|
||||||
|
../../modules/vmNetwork.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# System configuration here
|
# System configuration here
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.hostName = "lobon";
|
networking.hostName = "lobon";
|
||||||
|
vmNetwork.ipv4 = "192.168.0.22";
|
||||||
system.stateVersion = "23.11";
|
system.stateVersion = "23.11";
|
||||||
|
|
||||||
sops.secrets = {
|
sops.secrets = {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
../../roles
|
../../roles
|
||||||
../../roles/vm.nix
|
../../roles/vm.nix
|
||||||
|
../../modules/vmNetwork.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# System configuration here
|
# System configuration here
|
||||||
|
@ -10,5 +11,6 @@
|
||||||
environment.systemPackages = [pkgs.git];
|
environment.systemPackages = [pkgs.git];
|
||||||
|
|
||||||
networking.hostName = "nodens";
|
networking.hostName = "nodens";
|
||||||
|
vmNetwork.ipv4 = "192.168.0.18";
|
||||||
system.stateVersion = "24.11";
|
system.stateVersion = "24.11";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
../../modules/mail.nix
|
../../modules/mail.nix
|
||||||
../../roles
|
../../roles
|
||||||
../../roles/vm.nix
|
../../roles/vm.nix
|
||||||
|
../../modules/vmNetwork.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# System configuration here
|
# System configuration here
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.hostName = "nyarlathotep";
|
networking.hostName = "nyarlathotep";
|
||||||
|
vmNetwork.ipv4 = "192.168.0.17";
|
||||||
system.stateVersion = "24.05";
|
system.stateVersion = "24.05";
|
||||||
|
|
||||||
sops.secrets = let
|
sops.secrets = let
|
||||||
|
|
|
@ -360,7 +360,7 @@ in {
|
||||||
# We don't want this in order to not need to persist borg cache and simplify new deployments.
|
# We don't want this in order to not need to persist borg cache and simplify new deployments.
|
||||||
BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK = "yes";
|
BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK = "yes";
|
||||||
};
|
};
|
||||||
repo = "borg@bragi:nyarlathotep"; # TODO for https://gitea.mathebau.de/Fachschaft/nixConfig/issues/33
|
repo = "borg@192.168.1.11:nyarlathotep"; # TODO for https://gitea.mathebau.de/Fachschaft/nixConfig/issues/33
|
||||||
startAt = "daily";
|
startAt = "daily";
|
||||||
user = "root";
|
user = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
|
|
|
@ -117,7 +117,7 @@ in {
|
||||||
# We don't want this in order to not need to persist borg cache and simplify new deployments.
|
# We don't want this in order to not need to persist borg cache and simplify new deployments.
|
||||||
BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK = "yes";
|
BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK = "yes";
|
||||||
};
|
};
|
||||||
repo = "borg@bragi:lobon"; # TODO for https://gitea.mathebau.de/Fachschaft/nixConfig/issues/33
|
repo = "borg@192.168.1.11:lobon"; # TODO for https://gitea.mathebau.de/Fachschaft/nixConfig/issues/33
|
||||||
startAt = "daily";
|
startAt = "daily";
|
||||||
user = "root";
|
user = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
|
|
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"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,57 +0,0 @@
|
||||||
# This data is taken from /etc/hosts from azatoth
|
|
||||||
{
|
|
||||||
bragi = {
|
|
||||||
ipv4 = "192.168.1.11";
|
|
||||||
};
|
|
||||||
tsathoggua = {
|
|
||||||
ipv4 = "192.168.0.13";
|
|
||||||
};
|
|
||||||
nyogtha = {
|
|
||||||
ipv4 = "192.168.0.14";
|
|
||||||
};
|
|
||||||
hastur = {
|
|
||||||
ipv4 = "192.168.0.15";
|
|
||||||
};
|
|
||||||
cthulhu = {
|
|
||||||
ipv4 = "192.168.0.16";
|
|
||||||
};
|
|
||||||
nyarlathotep = {
|
|
||||||
ipv4 = "192.168.0.17";
|
|
||||||
};
|
|
||||||
nodens = {
|
|
||||||
ipv4 = "192.168.0.18";
|
|
||||||
};
|
|
||||||
uvhash = {
|
|
||||||
ipv4 = "192.168.0.19";
|
|
||||||
};
|
|
||||||
aphoom-zhah = {
|
|
||||||
ipv4 = "192.168.0.20";
|
|
||||||
};
|
|
||||||
dagon = {
|
|
||||||
ipv4 = "192.168.0.21";
|
|
||||||
};
|
|
||||||
lobon = {
|
|
||||||
ipv4 = "192.168.0.22";
|
|
||||||
};
|
|
||||||
yibb-tstll = {
|
|
||||||
ipv4 = "192.168.0.23";
|
|
||||||
};
|
|
||||||
eihort = {
|
|
||||||
ipv4 = "192.168.0.24";
|
|
||||||
};
|
|
||||||
ghatanothoa = {
|
|
||||||
ipv4 = "192.168.0.25";
|
|
||||||
};
|
|
||||||
toth = {
|
|
||||||
ipv4 = "192.168.0.26";
|
|
||||||
};
|
|
||||||
ithaqua = {
|
|
||||||
ipv4 = "192.168.0.27";
|
|
||||||
};
|
|
||||||
cthugha = {
|
|
||||||
ipv4 = "192.168.0.30";
|
|
||||||
};
|
|
||||||
sanctamariamaterdei = {
|
|
||||||
ipv4 = "192.168.0.92";
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
{modulesPath, ...}: {
|
{modulesPath, ...}: {
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/virtualisation/xen-domU.nix")
|
(modulesPath + "/virtualisation/xen-domU.nix")
|
||||||
./vmNetwork.nix
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib) mapAttrsToList;
|
|
||||||
inherit (lib.attrsets) foldAttrs concatMapAttrs;
|
|
||||||
inherit (lib.asserts) assertMsg;
|
|
||||||
inherit (lib.lists) filter last init;
|
|
||||||
inherit (lib.strings) splitString toInt concatStringsSep;
|
|
||||||
inherit (builtins) elem toString;
|
|
||||||
hostmap = import ./hostmap.nix;
|
|
||||||
myhostName = config.networking.hostName;
|
|
||||||
# To turn the hostmap around suitable for networking.hosts the following simple code almost works
|
|
||||||
# concatMapAttrs (hostname: ipData: { ${ipData.ipv4} = [hostname]; }) hostmap
|
|
||||||
# but breaks as soon as we want to map two different names to the same ip.
|
|
||||||
# So the code looks uglier than one would expect.
|
|
||||||
globalhosts = foldAttrs (a: b: a ++ b) [] (mapAttrsToList (hostname: ipData: {${ipData.ipv4} = [hostname];}) hostmap);
|
|
||||||
# We replace our own ip with 127.0.0.1 in /etc/hosts
|
|
||||||
myhosts = concatMapAttrs (ip: hosts:
|
|
||||||
if (elem myhostName hosts)
|
|
||||||
# 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
|
|
||||||
then {"127.0.0.1" = filter (x: x != myhostName) hosts;}
|
|
||||||
else {${ip} = hosts;})
|
|
||||||
globalhosts;
|
|
||||||
myIp = assert (assertMsg (hostmap ? ${myhostName}.ipv4) "${myhostName} has no ip configured in nixos/roles/hostmap.nix"); hostmap.${myhostName}.ipv4;
|
|
||||||
in {
|
|
||||||
networking = {
|
|
||||||
hosts = myhosts;
|
|
||||||
interfaces.enX0.ipv4.addresses = [
|
|
||||||
{
|
|
||||||
address = 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