Skip to content

Referential opacity exposed by the module system #217

Closed

Description

@shlevy
$ 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.

Activity

  1. self-assigned this
    on Feb 27, 2014
  2. added a commit that references this issue on Jan 1, 2024
  3. added a commit that references this issue on Mar 5, 2026
  4. added 4 commits that reference this issue on Aug 9, 2026
  5. 2 remaining items

  6. added 15 commits that reference this issue on Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions