Subject: bug#36443: guix build mixes build dirs?

From: Mark H Weaver <[email-masked]>
Date: Sun, 30 Jun 2019 13:30:59 -0400

Mark H Weaver <[email-masked]> writes:

> Robert Vollmert <[email-masked]> writes:
>
>> So this is pretty bizarre, and I haven’t managed to cut it down
>> to a smaller example yet, but it seems pretty clear that something
>> is broken:
>>
>> $ guix build -K some-package
>> -> error, referencing /tmp/guix-build-puzzledb-frontend-20190625-git.drv-0
>> note: keeping build directory `/tmp/guix-build-puzzledb-frontend-20190625-git.drv-0’
>> $ guix build -K some-package
>> -> same error, again referencing /tmp/guix-build-puzzledb-frontend-20190625-git.drv-0
>> note: keeping build directory `/tmp/guix-build-puzzledb-frontend-20190625-git.drv-1’
>
> This is known behavior, and intentional.  The build is done within a
> container, and the directory name within the container is canonicalized.

FYI, here's the relevant commit that added this behavior:

--8<---------------cut here---------------start------------->8---
commit cb9601029ea164b86bdf997f7160d494c15d344b
Author: Eelco Dolstra <[email-masked]>
Date:   Wed Dec 2 14:59:07 2015 +0100

    daemon: Use deterministic $TMPDIR in chroot.
    
    Rather than using $<host-TMPDIR>/nix-build-<drvname>-<number>, the
    temporary directory is now always /tmp/nix-build-<drvname>-0. This
    improves bitwise-exact reproducibility for builds that store $TMPDIR
    in their build output. (Of course, those should still be fixed...)
    
    * nix/libstore/build.cc (DerivationGoal)[tmpDirInSandbox]: New field.
    (DerivationGoal::startBuilder): Initialize 'useChroot' earlier.  Compute
    'tmpDirInSandbox', and use it when populating 'dirsInChroot'.
    * doc/guix.texi (Build Environment Setup): Document it.
    
    Co-authored-by: Ludovic Courtès <[email-masked]>
--8<---------------cut here---------------end--------------->8---

       Mark