Hello, thank you very much for these snippets. I'm a lazy guy :-) so I wrapped this into a script, which starts a new bash with this environment (see attachment). Maybe this could be enhanced using guix mechanisms? Suggestions are welcome.
Usage: ./pkg-env # go into latest failed build - very convenient :-) ./pkg-env some-package # go into latest failed build of this package ./pkg-env /tmp/guix-build-some-package-1.4.01.drv-1 # go into this directory > That would probably make a good “Debugging Build Failures” section. Absolutely! -- Regards Hartmut Goebel | Hartmut Goebel | [email protected] | | www.crazy-compilers.com | compilers which you thought are impossible |
#!/bin/bash # Copyright © 2017 Hartmut Goebel <[email protected]> # License: GNU Public License v3.0 or (at your choice) later PACKAGE="${1}" if [ -z "${PACKAGE}" ] ; then PACKAGE=$(ls -td /var/tmp/guix-build-*.drv-* /tmp/guix-build-"$PACKAGE"-* 2>/dev/null | head -1) echo >&2 "No package name given, using $PACKAGE" elif [ "${PACKAGE#/var/tmp/}" = "$PACKAGE" ] ; then PACKAGE=$(ls -td /var/tmp/guix-build-"$PACKAGE"-* /tmp/guix-build-"$PACKAGE"-* 2>/dev/null | head -1) fi if [ ! -d "$PACKAGE" ] ; then echo >&2 "Not found: $PACKAGE" exit 10 fi #echo "Using $PACKAGE" # TODO: Support containers: # guix environment -C foo --ad-hoc strace gdb # rm /bin/sh # to be really like in the guix-daemon environment inifile=$(mktemp) cat > $inifile <<EOF cd $PACKAGE source $PACKAGE/environment-variables set +x cd \$(find . -maxdepth 1 -mindepth 1 -type d 2>/dev/null) . echo \$PWD EOF #echo '------------' ; cat $inifile ; echo '------------' env -i HOME=/tmp bash --noprofile --init-file $inifile rm -f $inifile
