{ pkgs, lib, config, ... }: with lib; let cfg = config.features.myvnc; myvnc = pkgs.writeScriptBin "myvnc" '' #!${pkgs.runtimeShell} uid=`id -u` port=$((9000+$uid)) shell=`getent passwd $(id -un) | awk -F : '{print $NF}'` vnc=${pkgs.turbovnc}/bin/vncserver # vnc=/nix/store/czp2b60dwk75widi8y287hr0xx1wgv2a-tigervnc-1.10.1/bin/vncserver case $1 in -p|--port) shift; port=$1 ;; kill|stop) display=$($vnc -list | sed -n 's/^\(:[0-9]\+\).*/\1/p'| head -1) $vnc -kill $display exit 0 ;; esac ps ax | sed '/grep/d' | grep "Xvnc.*-rfbport $port" >/dev/null 2>&1 [ $? = 1 ] && $vnc -rfbport $port echo "Xvnc server is running on port $port." # exec $shell -i ''; configuration = { services.xserver.windowManager.fluxbox.enable = true; environment.systemPackages = with pkgs; [ alacritty myvnc ]; }; in { options.features.myvnc = { enable = mkEnableOption "Enable mynvc script"; }; config = mkMerge [ (mkIf config.features.myvnc.enable configuration) ]; }