Confounding error when building my system—access to store is “forbidden in pure eval mode”?

The source for my NixOS configuration is here: GitHub - schuelermine/nixos-configuration
I built revision e3b74081d623629f47388cb5c8b157957c907821.

At any rate, I did sudo nixos-rebuild switch, and got the error

error: access to absolute path ‘/nix/store/wkrhbbyg6wkiq3lkr3b2nz12c6ylk4vg-sourceboot.nix’ is forbidden in pure eval mode (use ‘–impure’ to override)

This seems beyond my control, and it’s very weird that a store path can’t be accessed (supposedly).

What’s going on?

Click to expand & see full trace
building the system configuration...
error: access to absolute path '/nix/store/wkrhbbyg6wkiq3lkr3b2nz12c6ylk4vg-sourceboot.nix' is forbidden in pure eval mode (use '--impure' to override)

       … while evaluating 'isFunction'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/trivial.nix:403:16:

          402|   */
          403|   isFunction = f: builtins.isFunction f ||
             |                ^
          404|     (f ? __functor && isFunction (f.__functor f));

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:369:68:

          368|
          369|   applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
             |                                                                    ^
          370|     let

       … while evaluating 'applyIfFunction'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:369:29:

          368|
          369|   applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
             |                             ^
          370|     let

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:276:59:

          275|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          276|         else unifyModuleSyntax (toString m) (toString m) (applyIfFunction (toString m) (import m) args);
             |                                                           ^
          277|

       … while evaluating 'unifyModuleSyntax'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:339:34:

          338|      of ‘options’, ‘config’ and ‘imports’ attributes. */
          339|   unifyModuleSyntax = file: key: m:
             |                                  ^
          340|     let

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:276:14:

          275|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          276|         else unifyModuleSyntax (toString m) (toString m) (applyIfFunction (toString m) (import m) args);
             |              ^
          277|

       … while evaluating 'loadModule'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:270:53:

          269|       # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
          270|       loadModule = args: fallbackFile: fallbackKey: m:
             |                                                     ^
          271|         if isFunction m || isAttrs m then

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:311:22:

          310|           let
          311|             module = loadModule args parentFile "${parentKey}:anon-${toString n}" x;
             |                      ^
          312|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while evaluating the attribute 'disabled'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:306:13:

          305|           collectResults = modules: {
          306|             disabled = concatLists (catAttrs "disabled" modules);
             |             ^
          307|             inherit modules;

       … while evaluating anonymous lambda

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:328:31:

          327|           disabledKeys = map moduleKey disabled;
          328|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                               ^
          329|         in map (attrs: attrs.module) (builtins.genericClosure {

       … from call site

       … while evaluating 'filterModules'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:324:36:

          323|       # modules recursively. It returns the final list of unique-by-key modules
          324|       filterModules = modulesPath: { disabled, modules }:
             |                                    ^
          325|         let

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:335:7:

          334|     in modulesPath: initialModules: args:
          335|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
             |       ^
          336|

       … while evaluating anonymous lambda

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:334:37:

          333|
          334|     in modulesPath: initialModules: args:
             |                                     ^
          335|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:180:25:

          179|       merged =
          180|         let collected = collectModules
             |                         ^
          181|           (specialArgs.modulesPath or "")

       … while evaluating 'reverseList'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/lists.nix:393:17:

          392|   */
          393|   reverseList = xs:
             |                 ^
          394|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:184:33:

          183|           ({ inherit lib options config specialArgs; } // specialArgs);
          184|         in mergeModules prefix (reverseList collected);
             |                                 ^
          185|

       … while evaluating 'zipAttrsWithNames'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/attrsets.nix:366:33:

          365|   */
          366|   zipAttrsWithNames = names: f: sets:
             |                                 ^
          367|     listToAttrs (map (name: {

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/attrsets.nix:382:40:

          381|   zipAttrsWith =
          382|     builtins.zipAttrsWith or (f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets);
             |                                        ^
          383|   /* Like `zipAttrsWith' with `(name: values: values)' as the function.

       … while evaluating anonymous lambda

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/attrsets.nix:382:34:

          381|   zipAttrsWith =
          382|     builtins.zipAttrsWith or (f: sets: zipAttrsWithNames (concatMap attrNames sets) f sets);
             |                                  ^
          383|   /* Like `zipAttrsWith' with `(name: values: values)' as the function.

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:446:9:

          445|       byName = attr: f: modules:
          446|         zipAttrsWith (n: concatLists)
             |         ^
          447|           (map (module: let subtree = module.${attr}; in

       … while evaluating 'byName'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:445:25:

          444|       */
          445|       byName = attr: f: modules:
             |                         ^
          446|         zipAttrsWith (n: concatLists)

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:462:21:

          461|       # an attrset 'name' => list of submodules that declare ‘name’.
          462|       declsByName = byName "options" (module: option:
             |                     ^
          463|           [{ inherit (module) _file; options = option; }]

       … while evaluating the attribute 'matchedOptions'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:506:14:

          505|     in {
          506|       inherit matchedOptions;
             |              ^
          507|

       … while evaluating 'mapAttrsRecursiveCond'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/attrsets.nix:296:36:

          295|   */
          296|   mapAttrsRecursiveCond = cond: f: set:
             |                                    ^
          297|     let

       … from call site

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:192:28:

          191|           # For definitions that have an associated option
          192|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                            ^
          193|

       … while evaluating the attribute 'config'

       at /nix/store/bfllm0im5z34n4v84zvip0kwy6vwl2yz-source/lib/modules.nix:257:9:

          256|         options = checked options;
          257|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          258|         _module = checked (config._module);

I’ve just been informed of my mistake on Matrix. I should’ve written ./modules + "/${name}" instead of ./. + name, which just appended name to the flake path w/o a slash. Thanks @oddtimes:matrix.org! Rev 6fb542974f5304185266596b2251e67a59b8a1b1 works now.

1 Like