From 50146ce815707a0772869c59db287d7dc2964799 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Mon, 18 May 2015 20:59:21 +0200 Subject: [PATCH] Add pkgs module argument documentation for #6794 incompatible change. --- nixos/doc/manual/release-notes/rl-1509.xml | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-1509.xml b/nixos/doc/manual/release-notes/rl-1509.xml index f41fdf7101da..404bf2dd810b 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 + + + Any use of module argument such as pkgs to access + library functions, or to define imports attributes + will now lead to an infinite loop at the time of the evaluation. + + + + In case of infinite loop, use the --show-trace + command line argument and read the line just above the error message. + + +$ nixos-rebuild build --show-trace +… +while evaluating the module argument `pkgs' in "/etc/nixos/my-module.nix": +infinite recursion encountered + + + + + + Any use of pkgs.lib, should be replaced by + lib, after adding it as argument of the module. The + following module + + +{ config, pkgs, ... }: + +with pkgs.lib; + +{ + options = { + foo = mkOption { … }; + }; + config = mkIf config.foo { … }; +} + + + should be modified to look like: + + +{ config, pkgs, lib, ... }: + +with lib; + +{ + options = { + foo = mkOption { option declaration }; + }; + config = mkIf config.foo { option definition }; +} + + + + + When pkgs is used to download other projects to + import their modules, and only in such cases, it should be replaced by + (import <nixpkgs> {}). The following module + + +{ config, pkgs, ... }: + +let + myProject = pkgs.fetchurl { + src = url; + sha256 = hash; + }; +in + +{ + imports = [ "${myProject}/module.nix" ]; +} + + + should be modified to look like: + + +{ config, pkgs, ... }: + +let + myProject = (import <nixpkgs> {}).fetchurl { + src = url; + sha256 = hash; + }; +in + +{ + imports = [ "${myProject}/module.nix" ]; +} + + + + +