liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

STYLE.md (1342B)


      1 # Some notes on Nix language style
      2 
      3 In an attempt to keep this more consistent than NixWRT ended up being,
      4 here is a Nix language style guide for this repo.
      5 
      6 * favour `callPackage` over raw `import` for calling derivations
      7 or any function that may generate one - any code that might need
      8 `pkgs` or parts of it.
      9 
     10 * prefer `let inherit (quark) up down strange charm` over `with
     11 quark`, in any context where the scope is more than a single
     12 expression or there is more than one reference to `up`, `down` etc.
     13 `with pkgs; [ foo bar baz]` is OK,
     14 `with lib; stdenv.mkDerivation { ... } ` is usually not.
     15 
     16 * <liminix> is defined only when running tests, so don't refer to it in
     17 "application" code
     18 
     19 * the parameters to a derivation are sorted alphabetically, except for
     20 `lib`, `stdenv` and maybe other non-package "special cases"
     21 
     22 * indentation is whatever emacs nix-mode says it is.
     23 
     24   * where a `let` form defines multiple names, put a newline after the
     25   token `let`, and indent each name two characters
     26 
     27 * should it be a package or a module? packages are self-contained -
     28   they live in /nix/store/eeeeeee-name and don't directly change
     29   system behaviour by their presence or absense. modules can add to
     30   /etc or /bin or other global state, create services, all that
     31   side-effecty stuff.  generally it should be a package unless it
     32   can't be.