diff --git a/doc/coding-conventions.xml b/doc/coding-conventions.xml index 3e4afdc1d4f5..586fcd98f23d 100644 --- a/doc/coding-conventions.xml +++ b/doc/coding-conventions.xml @@ -152,6 +152,52 @@ stdenv.mkDerivation { ... , # Some comment... argN }: + + + + + Functions should list their expected arguments as + precisely as possible. That is, write + + +{ stdenv, fetchurl, perl }: ... + + + instead of + + +args: with args; ... + + + or + + +{ stdenv, fetchurl, perl, ... }: ... + + + + + For functions that are truly generic in the number of + arguments (such as wrappers around mkDerivation) + that have some required arguments, you should write them using an + @-pattern: + + +{ stdenv, doCoverageAnalysis ? false, ... } @ args: + +stdenv.mkDerivation (args // { + ... if doCoverageAnalysis then "bla" else "" ... +}) + + + instead of + + +args: + +args.stdenv.mkDerivation (args // { + ... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ... +})