# posh makes use of podman to run an encapsulated shell session { pkgs, ... }: { image, pull ? "always", global_args ? "", run_args ? "" }: (pkgs.writeScriptBin "posh" '' #! ${pkgs.bash}/bin/bash source /etc/profile test -S "$SSH_AUTH_SOCK" && ssh="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK" tty -s && tty="-t" || quiet="-q" # define these as variables so we can override them at runtime POSH_IMAGE=${image} POSH_PULL=${pull} if [ "$1" == "-c" ]; then # We've most likely been spawned by sshd and are interested in $2 whitch contains the command string shift # TODO parse the beginning of the command for POSH_* overrides fi exec ${pkgs.podman}/bin/podman \ ${global_args} run --rm -i $tty $ssh -v ~/:/root -w /root --network host --pull=''${POSH_PULL} \ ${run_args} ''${POSH_IMAGE} $@ '') .overrideAttrs(attrs: attrs // { passthru = { shellPath = "/bin/posh"; }; })