diff options
author | Nicolas B. Pierron <nicolas.b.pierron@gmail.com> | 2015-05-18 20:59:21 +0200 |
---|---|---|
committer | Nicolas B. Pierron <nicolas.b.pierron@gmail.com> | 2015-09-30 21:13:42 +0200 |
commit | 50146ce815707a0772869c59db287d7dc2964799 (patch) | |
tree | e831cb7314bc193c205d053160894ceae2bf6fd8 /nixos/doc/manual/release-notes | |
parent | 4eb5068a13a934ee85f962cce464d7a9692c71b1 (diff) |
Add pkgs module argument documentation for #6794 incompatible change.
Diffstat (limited to 'nixos/doc/manual/release-notes')
-rw-r--r-- | nixos/doc/manual/release-notes/rl-1509.xml | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/nixos/doc/manual/release-notes/rl-1509.xml b/nixos/doc/manual/release-notes/rl-1509.xml index f41fdf7101da4..404bf2dd810bc 100644 --- a/nixos/doc/manual/release-notes/rl-1509.xml +++ b/nixos/doc/manual/release-notes/rl-1509.xml @@ -347,6 +347,100 @@ nix-env -f "<nixpkgs>" -iA haskellPackages.pandoc </para> </listitem> +<listitem> + <para> + Any use of module argument such as <varname>pkgs</varname> to access + library functions, or to define <literal>imports</literal> attributes + will now lead to an infinite loop at the time of the evaluation. + </para> + + <para> + In case of infinite loop, use the <command>--show-trace</command> + command line argument and read the line just above the error message. + +<screen> +$ nixos-rebuild build --show-trace +… +while evaluating the module argument `pkgs' in "/etc/nixos/my-module.nix": +infinite recursion encountered +</screen> + </para> + + + <para> + Any use of <literal>pkgs.lib</literal>, should be replaced by + <varname>lib</varname>, after adding it as argument of the module. The + following module + +<programlisting> +{ config, pkgs, ... }: + +with pkgs.lib; + +{ + options = { + foo = mkOption { … }; + }; + config = mkIf config.foo { … }; +} +</programlisting> + + should be modified to look like: + +<programlisting> +{ config, pkgs, lib, ... }: + +with lib; + +{ + options = { + foo = mkOption { <replaceable>option declaration</replaceable> }; + }; + config = mkIf config.foo { <replaceable>option definition</replaceable> }; +} +</programlisting> + </para> + + <para> + When <varname>pkgs</varname> is used to download other projects to + import their modules, and only in such cases, it should be replaced by + <literal>(import <nixpkgs> {})</literal>. The following module + +<programlisting> +{ config, pkgs, ... }: + +let + myProject = pkgs.fetchurl { + src = <replaceable>url</replaceable>; + sha256 = <replaceable>hash</replaceable>; + }; +in + +{ + imports = [ "${myProject}/module.nix" ]; +} +</programlisting> + + should be modified to look like: + +<programlisting> +{ config, pkgs, ... }: + +let + myProject = (import <nixpkgs> {}).fetchurl { + src = <replaceable>url</replaceable>; + sha256 = <replaceable>hash</replaceable>; + }; +in + +{ + imports = [ "${myProject}/module.nix" ]; +} +</programlisting> + </para> + +</listitem> + </itemizedlist> </para> |