at 18.09-beta 1.1 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.programs.mosh; 8 9in 10{ 11 options.programs.mosh = { 12 enable = mkOption { 13 description = '' 14 Whether to enable mosh. Note, this will open ports in your firewall! 15 ''; 16 default = false; 17 type = lib.types.bool; 18 }; 19 withUtempter = mkOption { 20 description = '' 21 Whether to enable libutempter for mosh. 22 This is required so that mosh can write to /var/run/utmp (which can be queried with `who` to display currently connected user sessions). 23 Note, this will add a guid wrapper for the group utmp! 24 ''; 25 default = true; 26 type = lib.types.bool; 27 }; 28 }; 29 30 config = mkIf cfg.enable { 31 environment.systemPackages = with pkgs; [ mosh ]; 32 networking.firewall.allowedUDPPortRanges = [ { from = 60000; to = 61000; } ]; 33 security.wrappers = mkIf cfg.withUtempter { 34 utempter = { 35 source = "${pkgs.libutempter}/lib/utempter/utempter"; 36 owner = "nobody"; 37 group = "utmp"; 38 setuid = false; 39 setgid = true; 40 }; 41 }; 42 }; 43}