Files
nix-dotfiles/home/programs/ssh/pvv.nix
T

111 lines
2.5 KiB
Nix

{ pkgs, lib, ... }:
let # http://www.pvv.ntnu.no/pvv/Maskiner
normalMachines = [
{
_names = [ "hildring" "pvv-login" ];
ProxyJump = lib.mkDefault null;
AddressFamily = "inet";
}
{
_names = [ "drolsum" "pvv-login2" "pvv" ];
ProxyJump = lib.mkDefault null;
AddressFamily = "inet";
}
"bakke"
[ "bekkalokk" "pvv-web" "pvv-wiki" "pvv-webmail" ]
[ "bicep" "pvv-databases" ]
"bikkje"
"bob"
[ "brzeczyszczykiewicz" "brez" "bokhylle" ]
"dagali"
"demiurgen"
"eirin"
"georg"
"gluttony"
"ildkule"
"isvegg"
"kommode"
"lupine-1"
"lupine-2"
"lupine-3"
"lupine-4"
"lupine-5"
{
_names = [ "microbel" "pvv-users" "pvv-mail" ];
ProxyJump = lib.mkDefault null;
AddressFamily = "inet";
}
"mirage"
"orchid"
"shark"
"skrott"
"tallulah"
"temmie"
"tom"
"ustetind"
"venture"
"wenche"
"wegonke"
];
rootMachines = [
[ "ameno" "pvv-dns" ]
[ "balduzius" "pvv-krb" ]
[ "innovation" "pvv-minecraft" ]
"knutsen"
"ludvigsen"
[ "principal" "pvv-backup" ]
[ "skrott" "dibbler" ]
{
_names = [ "sleipner" "pvv-salt" ];
User = "oysteikt/admin";
}
"buskerud"
"smask"
[ "blossom" "powerpuff1" "powerpuff" ]
[ "bubbles" "powerpuff2" ]
[ "buttercup" "powerpuff3" ]
];
overrideIfNotExists = b: a: a // (builtins.removeAttrs b (builtins.attrNames a));
coerce = User: machines: lib.pipe machines [
(m: if builtins.isString m then { _names = [m]; } else m)
(m: if builtins.isList m then { _names = m; } else m)
(overrideIfNotExists { inherit User; })
];
normalUser = "oysteikt";
matchConfig = let
machines = (map (coerce normalUser) normalMachines) ++ (map (m: (coerce "root" m) // {
SetEnv = {
LOGNAME_OVERRIDE = "%u";
};
}) rootMachines);
setVars = orig@{ _names, ... }: {
name = builtins.concatStringsSep " " _names;
value = overrideIfNotExists {
Hostname = "${builtins.head _names}.pvv.ntnu.no";
ProxyJump = "microbel";
AddressFamily = "inet";
} (builtins.removeAttrs orig ["_names"]);
};
in builtins.listToAttrs (map setVars machines);
in
{
programs.ssh.settings = lib.mergeAttrsList [
matchConfig
{
"pvv-git git.pvv.ntnu.no" = {
Hostname = "git.pvv.ntnu.no";
User = "gitea";
AddressFamily = "inet";
Port = 2222;
ProxyJump = "microbel";
};
}
];
}