Skip to content

Instantly share code, notes, and snippets.

@adnelson
Created September 8, 2015 17:39
Show Gist options
  • Save adnelson/c399697a3cae6cb9a210 to your computer and use it in GitHub Desktop.
Save adnelson/c399697a3cae6cb9a210 to your computer and use it in GitHub Desktop.
This should output something with PV, but it doesn't.
with import <pkgs>;
stdenv.mkDerivation {
name = "test_of_stuff";
buildInputs = [python pv];
buildCommand = ''
echo "doing some random stuff..."
cat <<EOF | python
import random, string, os
letters = string.letters + ' '
f = open(os.path.join(os.environ['TMPDIR'], 'data.dat'), 'w')
for i in range(100000):
f.write(random.choice(letters))
EOF
_size="$(du -sk $TMPDIR/data.dat | awk '{s+=$1} END {print s}')k"
tar -cf - $TMPDIR/data.dat | pv -pte -s $_size | gzip > $TMPDIR/data.tar.gz
ls -l $TMPDIR/data.*
echo "done"
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment