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

84 lines
2.0 KiB
Nix
Raw Normal View History

{ pkgs, lib, ... }:
2024-11-29 01:35:14 +01:00
let # http://www.pvv.ntnu.no/pvv/Maskiner
2022-03-07 16:01:52 +01:00
normalMachines = [
{
2024-11-29 01:35:14 +01:00
names = [ "hildring" "pvv-login" ];
proxyJump = lib.mkDefault null;
2024-12-02 08:13:06 +01:00
addressFamily = "inet";
2024-11-29 01:35:14 +01:00
}
{
names = [ "drolsum" "pvv-login2" "pvv" ];
proxyJump = lib.mkDefault null;
2024-12-02 08:13:06 +01:00
addressFamily = "inet";
}
2024-09-04 10:29:31 +02:00
[ "bekkalokk" "pvv-web" "pvv-wiki" "pvv-webmail" ]
[ "bicep" "pvv-databases" ]
"bob"
[ "brzeczyszczykiewicz" "brez" "bokhylle" ]
"buskerud"
"dagali"
2022-03-07 16:01:52 +01:00
"demiurgen"
"eirin"
2024-09-04 10:29:31 +02:00
"georg"
"ildkule"
2022-03-07 16:01:52 +01:00
"isvegg"
2024-09-04 10:29:31 +02:00
"knutsen"
2022-03-07 16:01:52 +01:00
[ "microbel" "pvv-users" "pvv-mail" ]
2024-09-04 10:29:31 +02:00
"orchid"
"shark"
"tallulah"
"tom"
"venture"
2022-03-07 16:01:52 +01:00
];
rootMachines = [
2024-09-04 10:29:31 +02:00
[ "ameno" "pvv-dns" ]
[ "balduzius" "pvv-krb" ]
2022-03-07 16:01:52 +01:00
[ "innovation" "pvv-minecraft" ]
2024-09-04 10:29:31 +02:00
"ludvigsen"
[ "principal" "pvv-backup" ]
[ "skrott" "dibbler" ]
2024-11-29 01:35:14 +01:00
{
names = [ "sleipner" "pvv-salt" ];
user = "oysteikt/admin";
}
2022-03-07 16:01:52 +01:00
];
2024-11-29 01:35:14 +01:00
overrideIfNotExists = b: a: a // (builtins.removeAttrs b (builtins.attrNames a));
2022-03-07 16:01:52 +01:00
2024-11-29 01:35:14 +01:00
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; })
];
2022-03-07 16:01:52 +01:00
2024-11-29 01:35:14 +01:00
normalUser = "oysteikt";
2022-03-07 16:01:52 +01:00
2024-11-29 01:35:14 +01:00
matchConfig = let
machines = (map (coerce normalUser) normalMachines) ++ (map (coerce "root") rootMachines);
setVars = orig@{ names, ... }: {
name = builtins.concatStringsSep " " names;
value = overrideIfNotExists {
hostname = "${builtins.head names}.pvv.ntnu.no";
proxyJump = "pvv";
addressFamily = "inet";
} (builtins.removeAttrs orig ["names"]);
};
in builtins.listToAttrs (map setVars machines);
2022-03-07 16:01:52 +01:00
in
{
programs.ssh.matchBlocks = lib.mergeAttrsList [
2024-11-29 01:35:14 +01:00
matchConfig
{
"pvv-git git.pvv.ntnu.no" = {
hostname = "git.pvv.ntnu.no";
user = "gitea";
addressFamily = "inet";
port = 2222;
proxyJump = "pvv";
};
}
];
2022-03-07 16:01:52 +01:00
}