2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.mosh;
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.programs.mosh = {
|
2024-01-02 11:29:13 +00:00
|
|
|
enable = lib.mkEnableOption "mosh";
|
|
|
|
openFirewall = lib.mkEnableOption "" // {
|
|
|
|
description = "Whether to automatically open the necessary ports in the firewall.";
|
|
|
|
default = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
withUtempter = lib.mkEnableOption "" // {
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable libutempter for mosh.
|
2024-01-02 11:29:13 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
This is required so that mosh can write to /var/run/utmp (which can be queried with `who` to display currently connected user sessions).
|
|
|
|
Note, this will add a guid wrapper for the group utmp!
|
|
|
|
'';
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkgs.mosh ];
|
|
|
|
networking.firewall.allowedUDPPortRanges = lib.optional cfg.openFirewall { from = 60000; to = 61000; };
|
|
|
|
security.wrappers = lib.mkIf cfg.withUtempter {
|
2020-04-24 23:36:52 +00:00
|
|
|
utempter = {
|
|
|
|
source = "${pkgs.libutempter}/lib/utempter/utempter";
|
2021-10-06 13:57:05 +00:00
|
|
|
owner = "root";
|
2020-04-24 23:36:52 +00:00
|
|
|
group = "utmp";
|
|
|
|
setuid = false;
|
|
|
|
setgid = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|