1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/configs/hu-berlin.nix

87 lines
2.6 KiB
Nix
Raw Normal View History

2022-03-10 21:52:12 +01:00
{
config,
pkgs,
lib,
...
}: let
2020-01-18 08:02:02 +01:00
inherit (lib.strings) fileContents;
inherit (import ../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
};
hu-berlin-cifs-options = [
"uid=${toString config.users.users.me.uid}"
"gid=${toString config.users.groups.users.gid}"
"sec=ntlmv2"
"workgroup=german"
"credentials=${config.age.secrets.cifs-credentials-hu-berlin.path}"
"noauto"
2023-03-28 11:03:14 +02:00
# "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 {
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;
};
age.secrets.cifs-credentials-hu-berlin.file = ../secrets/cifs-credentials-hu-berlin.age;
2021-12-02 14:19:14 +01:00
home-manager.users.me.programs.ssh = {
matchBlocks = {
"alew.hu-berlin.de" = {
user = "centos";
hostname = "141.20.187.219";
};
};
};
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
'')
2022-03-10 21:52:12 +01:00
(
pkgs.writers.writePython3Bin "hu-eduroam-install"
{
2022-03-10 21:52:12 +01:00
libraries = with pkgs.python3Packages; [distro pyopenssl dbus-python];
flakeIgnore = ["E501" "E123" "W504" "E722" "F821" "E226" "E126" "E265" "W291"];
}
(builtins.readFile (builtins.fetchurl {
url = "https://www.cms.hu-berlin.de/de/dl/netze/wlan/config/eduroam/linux-installer/eduroam-linux-hub.py";
sha256 = "19x2kvwxx13265b2hj5fjf53g0liw6dw7xf9j9cav67cswmz60kf";
}))
)
2020-12-28 19:50:34 +01:00
];
systemd.services.hu-vpn = {
2021-12-13 11:57:27 +01:00
enable = true;
2022-03-10 21:52:12 +01:00
wants = ["network-online.target"];
serviceConfig.LoadCredential = "password:${config.age.secrets.email-password-meinhark.path}";
script = ''
2023-03-28 11:03:14 +02:00
if ${pkgs.wirelesstools}/bin/iwgetid | ${pkgs.gnugrep}/bin/grep --invert-match eduroam
then
${pkgs.openfortivpn}/bin/openfortivpn \
--password="$(cat "$CREDENTIALS_DIRECTORY/password")" \
--config=${
2022-03-10 21:52:12 +01:00
pkgs.writeText "hu-berlin.config" ''
host = forti-ssl.vpn.hu-berlin.de
port = 443
username = meinhark
trusted-cert = 9e5dea8e077970d245900839f437ef7fb9551559501c7defd70af70ea568573d
2022-03-10 21:52:12 +01:00
''
}
2023-03-28 11:03:14 +02:00
fi
'';
};
2019-01-08 18:22:54 +01:00
}