[Nix-dev] env-vars for builderDefs ?

Marc Weber marco-oweber at gmx.de
Sat Aug 22 00:06:22 CEST 2009


When a build fails I always cd into the failed directory, source
env-vars and start debugging.

What do you prefer:
a) optionally write the file
 pro: one line less in the builder script
 con: you have to rebuild the package and wait until it fails again

b) always write the file
 con: you always write the env-var which is cleaned up afterwards.
  
I'd prefer a).

How do you like this implementation (untested):

Because a trap was already used it introduces the TRAP env var which is
evaled on EXIT. This way you can add additional TRAP actions easily.

By the way:
  a) Isn't the EXIT trap action run in all cases?
  So is stopNest executed twice at the end? Probably it doesn't matter.

  b) Does it make sens to replace " by '' in
  pkgs/top-level/../build-support/builder-defs/builder-defs.nix ?
  Because the additional whitespaces added by "" because indentation is
  not removed count up as well. What a waste of disk space in
  /nix/store/*.drv.. Do you agree?

  Index: pkgs/build-support/builder-defs/builder-defs.nix
  ===================================================================
  --- pkgs/build-support/builder-defs/builder-defs.nix	(revision 16805)
  +++ pkgs/build-support/builder-defs/builder-defs.nix	(working copy)
  @@ -83,7 +83,7 @@
                                           done
                   }
   
  -                trap \"closeNest\" EXIT
  +                TRAP=\"closeNest;\$TRAP\"
           ");
   
           minInit = fullDepEntry ("
  @@ -408,6 +408,9 @@
                   (attrByPath ["extraDoc"] [] args)))) ["minInit" "defEnsureDir" "doUnpack"];
   
           realPhaseNames = 
  +          # write env-vars file which is useful for debugging builds 
  +          [ (noDepEntry ''trap 'eval $TRAP' EXIT; TRAP='export > "$NIX_BUILD_TOP/env-vars"' EXIT'') ]
  +          ++
            (optional ([] != attrByPath ["neededDirs"] [] args) "createDirs")
            ++
            args.phaseName

Marc Weber



More information about the nix-dev mailing list