{ stdenv, xterm }:
stdenv.mkDerivation {
name = "util-1";
phases = "installPhase fixupPhase";
installPhase = ''
mkdir -pv $out/bin
cat << EOF > $out/bin/loginto
#!/bin/bash
exec ${xterm}/bin/xterm -e ssh \$1 -t screen -xRRU
EOF
chmod +x $out/bin/loginto
cat << EOF > $out/bin/showsize
#!/bin/bash
nix-store --query --tree "\$1" | sed 's,[-+| ]*/,/,' | awk '{print \$1}' | sort | uniq | xargs nix-store --query --size | paste -sd+ | ( echo -n '( ';sed 's,+, + ,g';echo ' ) / 1024 / 1024' ) | xargs expr
EOF
chmod +x $out/bin/showsize
cat << EOF > $out/bin/nix-lookup
#!/bin/bash
local USAGE
USAGE="$USAGE Usage: nix-lookup <expression-path-under-pkgs>"
USAGE="$USAGE Shows the directory for the given attribute path."
if [ $# -ne 1 ]; then echo "$USAGE"; return -1; fi
nix-instantiate --eval -E "\"\''${(import <nixpkgs> {}).pkgs.$1}\"" | sed 's:"::g'
EOF
chmod +x $out/bin/nix-lookup
cp -v ${./newer-example.sh} $out/bin/newer-example.sh
chmod +x $out/bin/newer-example.sh
'';
}