From 91154416b650e7a09c44b0c0d97399bc5c849117 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Tue, 14 Nov 2017 18:59:27 +0100 Subject: [PATCH] docs: clarify package and module option naming This attempts to briefly clarify the current naming conventions of attribute names in `all-packages.nix` and module option names. --- doc/coding-conventions.xml | 25 ++++++++++--------- .../development/option-declarations.xml | 9 +++++++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/doc/coding-conventions.xml b/doc/coding-conventions.xml index 0776e70f14e..ec81c968e4a 100644 --- a/doc/coding-conventions.xml +++ b/doc/coding-conventions.xml @@ -18,9 +18,9 @@ tab settings so it’s asking for trouble. Use lowerCamelCase for variable - names, not UpperCamelCase. TODO: naming of - attributes in - all-packages.nix? + names, not UpperCamelCase. Note, this rule does + not apply to package attribute names, which instead follow the rules + in . Function calls with attribute set arguments are written as @@ -220,9 +220,10 @@ args.stdenv.mkDerivation (args // { The variable name used for the instantiated package in all-packages.nix, and when passing it as a - dependency to other functions. This is what Nix expression authors - see. It can also be used when installing using nix-env - -iA. + dependency to other functions. Typically this is called the + package attribute name. This is what Nix + expression authors see. It can also be used when installing using + nix-env -iA. The filename for (the directory containing) the Nix expression. @@ -259,12 +260,12 @@ bound to the variable name e2fsprogs in Also append "unstable" to the name - e.g., "pkgname-unstable-2014-09-23". - Dashes in the package name should be preserved - in new variable names, rather than converted to underscores - (which was convention up to around 2013 and most names - still have underscores instead of dashes) — e.g., - http-parser instead of - http_parser. + Dashes in the package name should be preserved in + new variable names, rather than converted to underscores or camel + cased — e.g., http-parser instead of + http_parser or httpParser. The + hyphenated style is preferred in all three package + names. If there are multiple versions of a package, this should be reflected in the variable names in diff --git a/nixos/doc/manual/development/option-declarations.xml b/nixos/doc/manual/development/option-declarations.xml index be793152f9e..ed718c89eb7 100644 --- a/nixos/doc/manual/development/option-declarations.xml +++ b/nixos/doc/manual/development/option-declarations.xml @@ -22,6 +22,15 @@ options = { }; +The attribute names within the name +attribute path must be camel cased in general but should, as an +exception, match the + +package attribute name when referencing a Nixpkgs package. For +example, the option services.nix-serve.bindAddress +references the nix-serve Nixpkgs package. + The function mkOption accepts the following arguments.