[Nix-dev] Re: env-vars for builderDefs ?
Marc Weber
marco-oweber at gmx.de
Sat Aug 22 13:04:09 CEST 2009
Excerpts from Peter Simons's message of Sat Aug 22 12:21:41 +0200 2009:
> How is writing the file optionally instead of unconditionally
Hi Peter. Sorry, there are two ways to read "contitionally".
a) Add the trap manually when needed.
b) clear trap at the end by adding trap "" EXIT;
a) is -1 line compared to adding it in any case
+0 lines compared to as is right now
b) is +2 lines compared to as is right now
I talked to MichaelRaskin today about this.
My new patch takes into account
a) that a new attr name should be created (Maybe overkill?) I don't care.
b) disregards TRAP="$TRAP; ..." because it doesn't make much sense.
If you really want to define another trap before this step you can just define it yourself by
TRAP "..." EXIT and adding another step adding the same trap to $TRAP.
-> http://dpaste.com/83937/ (complete example)
c) it adds set +e ensuring that all traps are actually called even if one
fails if you append new traps by TRAP="$TRAP; yourtrapcode"
I think this change is reasonable. If no futher suggestions appear I'll commit this to stdenv updates.
I'll also rewrite ".." by ''..'' to remove some spaces and clean up those tabs.
Is there any reason to not commit these changes to stdenv-updates right now?
Marc Weber
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 ("
@@ -407,7 +407,13 @@
(x: ''cp "${x}" "$out/share/doc/$name" || true;'')
(attrByPath ["extraDoc"] [] args)))) ["minInit" "defEnsureDir" "doUnpack"];
+ # add additional traps by adding a step containing TRAP="$TRAP; your trap code";
+ # write env-vars file which is useful for debugging builds. Writing it in any case should be cheap.
+ setEnvVarTrap = (noDepEntry ''trap 'eval $TRAP' EXIT; TRAP='set +e; export > "$NIX_BUILD_TOP/env-vars"' EXIT'');
+
realPhaseNames =
+ [ setEnvVarTrap ]
+ ++
(optional ([] != attrByPath ["neededDirs"] [] args) "createDirs")
++
args.phaseNames
More information about the nix-dev
mailing list