blob: 3679ecf5a2d2ebc350082ebcecec0590dee7fa4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
{
pkgs,
inputs,
...
}: let
yossh =
pkgs.writeText "yossh.lua"
# lua
''
yoshi = dofile'${inputs.yoshi-lua}/yoshi.lua'
local function isHome()
local _, _, code = os.execute("nc -z -w1 192.168.50.2 2222")
return code == 0
end
yoshi.hosts["ganymede"] = function()
if isHome() then
return yoshi.ssh{
HostName = "192.168.50.2",
Port = 2222
}
else
return yoshi.ssh{
HostName = "williamsfam.us.com",
DynamicForward = 9090
}
end
end
yoshi.hosts["io"] = function()
if isHome() then
return yoshi.ssh{
HostName = "192.168.50.3",
User = "admin",
}
else
return yoshi.ssh{
HostName = "192.168.50.3",
User = "admin",
ProxyJump = "collin@ganymede",
}
end
end
yoshi.run(arg)
'';
in
pkgs.writeShellScriptBin "yossh" ''
exec ${pkgs.lua}/bin/lua ${yossh} "$@"
''
|