mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
e65131e69c
This process was automated by [my fork of `nix-doc-munge`]; thanks to @pennae for writing this tool! It automatically checks that the resulting documentation doesn't change, although my fork loosens this a little to ignore some irrelevant whitespace and typographical differences. As of this commit there is no DocBook remaining in the options documentation. You can play along at home if you want to reproduce this commit: $ NIX_PATH=nixpkgs=flake:nixpkgs/c1bca7fe84c646cfd4ebf3482c0e6317a0b13f22 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run github:emilazy/nix-doc-munge/0a7190f600027bf7baf6cb7139e4d69ac2f51062 \ {} + [my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge
106 lines
2.8 KiB
Nix
106 lines
2.8 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.autossh;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.autossh = {
|
|
|
|
sessions = mkOption {
|
|
type = types.listOf (types.submodule {
|
|
options = {
|
|
name = mkOption {
|
|
type = types.str;
|
|
example = "socks-peer";
|
|
description = lib.mdDoc "Name of the local AutoSSH session";
|
|
};
|
|
user = mkOption {
|
|
type = types.str;
|
|
example = "bill";
|
|
description = lib.mdDoc "Name of the user the AutoSSH session should run as";
|
|
};
|
|
monitoringPort = mkOption {
|
|
type = types.int;
|
|
default = 0;
|
|
example = 20000;
|
|
description = lib.mdDoc ''
|
|
Port to be used by AutoSSH for peer monitoring. Note, that
|
|
AutoSSH also uses mport+1. Value of 0 disables the keep-alive
|
|
style monitoring
|
|
'';
|
|
};
|
|
extraArguments = mkOption {
|
|
type = types.str;
|
|
example = "-N -D4343 bill@socks.example.net";
|
|
description = lib.mdDoc ''
|
|
Arguments to be passed to AutoSSH and retransmitted to SSH
|
|
process. Some meaningful options include -N (don't run remote
|
|
command), -D (open SOCKS proxy on local port), -R (forward
|
|
remote port), -L (forward local port), -v (Enable debug). Check
|
|
ssh manual for the complete list.
|
|
'';
|
|
};
|
|
};
|
|
});
|
|
|
|
default = [];
|
|
description = lib.mdDoc ''
|
|
List of AutoSSH sessions to start as systemd services. Each service is
|
|
named 'autossh-{session.name}'.
|
|
'';
|
|
|
|
example = [
|
|
{
|
|
name="socks-peer";
|
|
user="bill";
|
|
monitoringPort = 20000;
|
|
extraArguments="-N -D4343 billremote@socks.host.net";
|
|
}
|
|
];
|
|
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = mkIf (cfg.sessions != []) {
|
|
|
|
launchd.daemons =
|
|
lib.fold ( s : acc : acc //
|
|
{
|
|
"autossh-${s.name}" =
|
|
let
|
|
mport = if s ? monitoringPort then s.monitoringPort else 0;
|
|
in
|
|
{
|
|
# To be able to start the service with no network connection
|
|
environment.AUTOSSH_GATETIME="0";
|
|
|
|
# How often AutoSSH checks the network, in seconds
|
|
environment.AUTOSSH_POLL="30";
|
|
|
|
command = "${pkgs.autossh}/bin/autossh -M ${toString mport} ${s.extraArguments}";
|
|
|
|
serviceConfig = {
|
|
KeepAlive = true;
|
|
UserName = "${s.user}";
|
|
};
|
|
};
|
|
}) {} cfg.sessions;
|
|
|
|
environment.systemPackages = [ pkgs.autossh ];
|
|
|
|
};
|
|
}
|