2020-10-31 20:52:10 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2019-01-08 18:22:54 +01:00
|
|
|
let
|
2020-01-18 08:02:02 +01:00
|
|
|
inherit (lib.strings) fileContents;
|
2020-10-31 20:52:10 +01:00
|
|
|
inherit (import <niveum/lib>) sshPort;
|
2019-06-18 09:23:20 +02:00
|
|
|
eduroam = {
|
2020-09-24 19:25:47 +02:00
|
|
|
identity = fileContents <secrets/eduroam/identity>;
|
|
|
|
|
password = fileContents <secrets/eduroam/password>;
|
2019-06-18 09:23:20 +02:00
|
|
|
};
|
2019-05-14 07:18:04 +02:00
|
|
|
eduroamAuth = ''
|
|
|
|
|
key_mgmt=WPA-EAP
|
|
|
|
|
eap=TTLS
|
|
|
|
|
proto=RSN
|
|
|
|
|
identity="${eduroam.identity}"
|
|
|
|
|
anonymous_identity="anonymous@wlan.hu-berlin.de"
|
|
|
|
|
altsubject_match="DNS:srv1-radius.cms.hu-berlin.de;DNS:srv2-radius.cms.hu-berlin.de"
|
|
|
|
|
password="${eduroam.password}"
|
2020-06-10 17:37:25 +02:00
|
|
|
ca_cert="${
|
|
|
|
|
pkgs.fetchurl {
|
|
|
|
|
url =
|
|
|
|
|
"https://www.cms.hu-berlin.de/de/dl/netze/wlan/config/eduroam/t-telesec_globalroot_class_2.pem";
|
|
|
|
|
sha256 = "0if8aqd06sid7a0vw009zpa087wxcgdd2x6z2zs4pis5kvyqj2dk";
|
|
|
|
|
}
|
|
|
|
|
}"
|
2019-05-14 07:18:04 +02:00
|
|
|
phase2="auth=PAP"
|
|
|
|
|
'';
|
2020-12-18 10:27:34 +01:00
|
|
|
hu-berlin-cifs-options = [
|
|
|
|
|
"uid=${toString config.users.users.me.uid}"
|
|
|
|
|
"gid=${toString config.users.groups.users.gid}"
|
|
|
|
|
"sec=ntlmv2"
|
|
|
|
|
"workgroup=german"
|
|
|
|
|
"username=meinhaki"
|
|
|
|
|
"password=${lib.strings.fileContents <secrets/mail/meinhaki>}"
|
|
|
|
|
"noauto"
|
|
|
|
|
"x-systemd.requires=hu-vpn.service"
|
|
|
|
|
"x-systemd.automount"
|
|
|
|
|
"x-systemd.device-timeout=1"
|
|
|
|
|
"x-systemd.idle-timeout=1min"
|
|
|
|
|
];
|
2019-01-08 18:22:54 +01:00
|
|
|
in {
|
|
|
|
|
networking.wireless.networks = {
|
2019-05-14 07:18:04 +02:00
|
|
|
eduroam_5GHz.auth = eduroamAuth;
|
|
|
|
|
eduroam.auth = eduroamAuth;
|
2019-01-08 18:22:54 +01:00
|
|
|
};
|
|
|
|
|
|
2020-12-18 10:27:34 +01:00
|
|
|
fileSystems."/media/hu-berlin/germpro2" = {
|
|
|
|
|
device = "//hugerm31c.user.hu-berlin.de/germpro2/ling";
|
|
|
|
|
fsType = "cifs";
|
|
|
|
|
options = hu-berlin-cifs-options;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fileSystems."/media/hu-berlin/germhome" = {
|
|
|
|
|
device = "//hugerm31c.user.hu-berlin.de/germhome/ling/meinhaki";
|
|
|
|
|
fsType = "cifs";
|
|
|
|
|
options = hu-berlin-cifs-options;
|
|
|
|
|
};
|
2020-10-31 20:52:10 +01:00
|
|
|
|
2020-12-28 19:50:34 +01:00
|
|
|
environment.systemPackages = [
|
|
|
|
|
(pkgs.writers.writeDashBin "hu-ip" ''
|
|
|
|
|
${pkgs.w3m}/bin/w3m -dump meineip.hu-berlin.de | head --lines=-4 | tail --lines=+3
|
|
|
|
|
'')
|
|
|
|
|
];
|
|
|
|
|
|
2020-12-18 10:27:34 +01:00
|
|
|
systemd.services.hu-vpn = {
|
2021-04-07 22:38:45 +02:00
|
|
|
enable = false;
|
2020-12-18 10:27:34 +01:00
|
|
|
wants = [ "network-online.target" ];
|
2021-02-06 11:17:13 +01:00
|
|
|
conflicts = [ "openvpn-hu-berlin.service" ];
|
2020-12-18 10:27:34 +01:00
|
|
|
script = ''
|
|
|
|
|
${pkgs.openfortivpn}/bin/openfortivpn -c ${pkgs.writeText "hu-berlin.config" ''
|
2020-09-03 19:16:27 +02:00
|
|
|
host = forti-ssl.vpn.hu-berlin.de
|
|
|
|
|
port = 443
|
2021-02-06 11:17:13 +01:00
|
|
|
trusted-cert = 42193a913d276d9eb86217612956e1e6464d6f07bed5393a4787c87adc4bd359
|
2020-09-03 19:16:27 +02:00
|
|
|
username = ${eduroam.identity}
|
2020-12-18 10:27:34 +01:00
|
|
|
password = ${eduroam.password}
|
2020-09-03 19:16:27 +02:00
|
|
|
''}
|
2020-12-18 10:27:34 +01:00
|
|
|
'';
|
|
|
|
|
};
|
2020-09-03 19:16:27 +02:00
|
|
|
|
2021-02-06 11:17:13 +01:00
|
|
|
systemd.services.openvpn-hu-berlin.conflicts = [ "hu-vpn.service" ];
|
|
|
|
|
|
2020-01-18 08:02:02 +01:00
|
|
|
services.openvpn.servers.hu-berlin = {
|
|
|
|
|
autoStart = false;
|
|
|
|
|
authUserPass = {
|
|
|
|
|
username = eduroam.identity;
|
|
|
|
|
password = eduroam.password;
|
2019-01-08 18:22:54 +01:00
|
|
|
};
|
2020-01-18 08:02:02 +01:00
|
|
|
config = fileContents (pkgs.fetchurl {
|
2020-06-10 17:37:25 +02:00
|
|
|
url =
|
|
|
|
|
"https://www.cms.hu-berlin.de/de/dl/netze/vpn/openvpn/hu-berlin.ovpn";
|
2020-01-18 08:02:02 +01:00
|
|
|
sha256 = "15b55aibik5460svjq2gwxrcyh6ay4k8savd6cd5lncgndmd8p8h";
|
|
|
|
|
});
|
2019-01-08 18:22:54 +01:00
|
|
|
};
|
|
|
|
|
}
|