Referential opacity exposed by the module system #217

Closed
shlevy opened this Issue Feb 27, 2014 · 0 comments

Comments

Projects
None yet
2 participants
@shlevy
Member

shlevy commented Feb 27, 2014

$ cat module.nix 
let
  lib = import <nixpkgs/lib>;
  eval = (lib.evalModules {
    modules = [ ({ options, lib, ... }:
      let
        tr1 = builtins.trace (builtins.typeOf options) null;
        tr2 = builtins.trace (builtins.typeOf options) null;
      in lib.seq tr1 {
        options = {
          foo = lib.seq tr2 {};
        };
      }
    ) ];
  }).options.foo;
in builtins.trace ''
  nix version is ${builtins.nixVersion}
  nixpkgs version is ${lib.nixpkgsVersion}'' (lib.seq eval {})
$ nix-instantiate module.nix 
trace: nix version is 1.7pre3488_36b90e7
nixpkgs version is 14.02pre39778.d5211b0
trace: lambda
trace: set

Note that the last two traces should be identical.

@edolstra edolstra self-assigned this Feb 27, 2014

@edolstra edolstra added bug labels Feb 27, 2014

@edolstra edolstra closed this in c9f6232 Feb 27, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment