nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.14k stars 1.85k forks source link

bug: #6114

Open cynic opened 4 days ago

cynic commented 4 days ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I run Syncthing to keep various files synchronised between machines. For reasons, I don't synchronise the files directly in .config; instead, I make symlinks from .config. For example, ~/.config/home-manager/home.nix is a symlink to ~/sync/dotfiles/home.nix.

Home Manager used to be able to do this—when I was using the unstable, non-flake version—but gives me this error when I now try it:

error:
       … from call site
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:45:18:
           44|   withExtraAttrs = rawModule:
           45|     let module = moduleChecks rawModule;
             |                  ^
           46|     in {

       … while calling 'moduleChecks'
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:32:18:
           31|
           32|   moduleChecks = raw:
             |                  ^
           33|     showWarnings (let

       … from call site
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:33:5:
           32|   moduleChecks = raw:
           33|     showWarnings (let
             |     ^
           34|       failed = collectFailed raw.config;

       … while calling 'showWarnings'
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:15:18:
           14|
           15|   showWarnings = res:
             |                  ^
           16|     let f = w: x: builtins.trace "warning: ${w}" x;

       … from call site
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:17:8:
           16|     let f = w: x: builtins.trace "warning: ${w}" x;
           17|     in fold f res res.config.warnings;
             |        ^
           18|

       … while calling 'foldr'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/lists.nix:121:20:
          120|   */
          121|   foldr = op: nul: list:
             |                    ^
          122|     let

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/lists.nix:128:8:
          127|         else op (elemAt list n) (fold' (n + 1));
          128|     in fold' 0;
             |        ^
          129|

       … while calling 'fold''
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/lists.nix:124:15:
          123|       len = length list;
          124|       fold' = n:
             |               ^
          125|         if n == len

       … while evaluating a branch condition
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/lists.nix:125:9:
          124|       fold' = n:
          125|         if n == len
             |         ^
          126|         then nul

       … while calling the 'length' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/lists.nix:123:13:
          122|     let
          123|       len = length list;
             |             ^
          124|       fold' = n:

       … while evaluating a branch condition
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:36:8:
           35|       failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);
           36|     in if failed == [ ] then
             |        ^
           37|       raw

       … from call site
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:34:16:
           33|     showWarnings (let
           34|       failed = collectFailed raw.config;
             |                ^
           35|       failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);

       … while calling 'collectFailed'
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:12:19:
           11|
           12|   collectFailed = cfg:
             |                   ^
           13|     map (x: x.message) (filter (x: !x.assertion) cfg.assertions);

       … while calling the 'map' builtin
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:13:5:
           12|   collectFailed = cfg:
           13|     map (x: x.message) (filter (x: !x.assertion) cfg.assertions);
             |     ^
           14|

       … while calling the 'filter' builtin
         at /nix/store/xdjkb8wcgnq5f58vissl5p8py8a8w0z9-source/modules/default.nix:13:25:
           12|   collectFailed = cfg:
           13|     map (x: x.message) (filter (x: !x.assertion) cfg.assertions);
             |                         ^
           14|

       … while evaluating the attribute 'config'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:334:9:
          333|         options = checked options;
          334|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          335|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:334:18:
          333|         options = checked options;
          334|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          335|         _module = checked (config._module);

       … while evaluating a branch condition
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:273:9:
          272|       checkUnmatched =
          273|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |         ^
          274|           let

       … in the left operand of the AND (&&) operator
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:273:72:
          272|       checkUnmatched =
          273|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |                                                                        ^
          274|           let

       … in the left operand of the AND (&&) operator
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:273:33:
          272|       checkUnmatched =
          273|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |                                 ^
          274|           let

       … while evaluating a branch condition
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:266:12:
          265|
          266|         in if declaredConfig._module.freeformType == null then declaredConfig
             |            ^
          267|           # Because all definitions that had an associated option ended in

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:254:28:
          253|           # For definitions that have an associated option
          254|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                            ^
          255|

       … while calling 'mapAttrsRecursiveCond'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/attrsets.nix:1200:5:
         1199|     f:
         1200|     set:
             |     ^
         1201|     let

       … while calling the 'mapAttrs' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/attrsets.nix:1209:5:
         1208|     in
         1209|     recurse [ ] set;
             |     ^
         1210|

       … while evaluating the attribute 'matchedOptions'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:692:15:
          691|     in {
          692|       inherit matchedOptions;
             |               ^
          693|

       … while calling the 'mapAttrs' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:683:24:
          682|
          683|       matchedOptions = mapAttrs (n: v: v.matchedOptions) resultsByName;
             |                        ^
          684|

       … while calling the 'mapAttrs' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:636:23:
          635|
          636|       resultsByName = mapAttrs (name: decls:
             |                       ^
          637|         # We're descending into attribute ‘name’.

       … while calling the 'zipAttrsWith' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:553:9:
          552|       declsByName =
          553|         zipAttrsWith
             |         ^
          554|           (n: concatLists)

       … while calling the 'map' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:555:12:
          554|           (n: concatLists)
          555|           (map
             |            ^
          556|             (module: let subtree = module.options; in

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:246:33:
          245|           ({ inherit lib options config specialArgs; } // specialArgs);
          246|         in mergeModules prefix (reverseList collected);
             |                                 ^
          247|

       … while calling 'reverseList'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/lists.nix:1116:17:
         1115|   */
         1116|   reverseList = xs:
             |                 ^
         1117|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;

       … while calling the 'genList' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/lists.nix:1117:27:
         1116|   reverseList = xs:
         1117|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;
             |                           ^
         1118|

       … while evaluating the second argument passed to builtins.genList

       … while calling the 'length' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/lists.nix:1117:13:
         1116|   reverseList = xs:
         1117|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;
             |             ^
         1118|

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:241:25:
          240|       merged =
          241|         let collected = collectModules
             |                         ^
          242|           class

       … while calling anonymous lambda
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:452:37:
          451|
          452|     in modulesPath: initialModules: args:
             |                                     ^
          453|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:453:7:
          452|     in modulesPath: initialModules: args:
          453|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
             |       ^
          454|

       … while calling 'filterModules'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:420:36:
          419|       # modules recursively. It returns the final list of unique-by-key modules
          420|       filterModules = modulesPath: { disabled, modules }:
             |                                    ^
          421|         let

       … while calling the 'map' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:447:12:
          446|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
          447|         in map (attrs: attrs.module) (genericClosure {
             |            ^
          448|           startSet = keyFilter modules;

       … while calling the 'genericClosure' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:447:39:
          446|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
          447|         in map (attrs: attrs.module) (genericClosure {
             |                                       ^
          448|           startSet = keyFilter modules;

       … while calling the 'filter' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:448:22:
          447|         in map (attrs: attrs.module) (genericClosure {
          448|           startSet = keyFilter modules;
             |                      ^
          449|           operator = attrs: keyFilter attrs.modules;

       … while calling anonymous lambda
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:446:31:
          445|           disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
          446|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                               ^
          447|         in map (attrs: attrs.module) (genericClosure {

       … in the argument of the not operator
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:446:40:
          445|           disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
          446|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                                        ^
          447|         in map (attrs: attrs.module) (genericClosure {

       … while calling the 'elem' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:446:40:
          445|           disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
          446|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                                        ^
          447|         in map (attrs: attrs.module) (genericClosure {

       … while calling the 'concatMap' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:445:26:
          444|
          445|           disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
             |                          ^
          446|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);

       … while calling the 'concatLists' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:402:24:
          401|           collectResults = modules: {
          402|             disabled = concatLists (catAttrs "disabled" modules);
             |                        ^
          403|             inherit modules;

       … while evaluating the attribute 'disabled'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:402:13:
          401|           collectResults = modules: {
          402|             disabled = concatLists (catAttrs "disabled" modules);
             |             ^
          403|             inherit modules;

       … while calling the 'concatLists' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:402:24:
          401|           collectResults = modules: {
          402|             disabled = concatLists (catAttrs "disabled" modules);
             |                        ^
          403|             inherit modules;

       … while evaluating a branch condition
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:413:25:
          412|             modules = collectedImports.modules;
          413|             disabled = (if module.disabledModules != [] then [{ file = module._file; disabled = module.disabledModules; }] else []) ++ collectedImports.disabled;
             |                         ^
          414|           }) initialModules);

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:407:22:
          406|           let
          407|             module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
             |                      ^
          408|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while calling anonymous lambda
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:366:11:
          365|         then
          366|           m:
             |           ^
          367|             if m._class != null -> m._class == class

       … while evaluating a branch condition
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:367:13:
          366|           m:
          367|             if m._class != null -> m._class == class
             |             ^
          368|             then m

       … in the left operand of the IMPL (->) operator
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:367:33:
          366|           m:
          367|             if m._class != null -> m._class == class
             |                                 ^
          368|             then m

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:407:35:
          406|           let
          407|             module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
             |                                   ^
          408|             collectedImports = collectStructuredModules module._file module.key module.imports args;

       … while calling 'loadModule'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:348:53:
          347|       # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
          348|       loadModule = args: fallbackFile: fallbackKey: m:
             |                                                     ^
          349|         if isFunction m then

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:361:14:
          360|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          361|         else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
             |              ^
          362|

       … while calling 'unifyModuleSyntax'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:461:34:
          460|      of ‘options’, ‘config’ and ‘imports’ attributes. */
          461|   unifyModuleSyntax = file: key: m:
             |                                  ^
          462|     let

       … while evaluating a branch condition
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:470:5:
          469|     in
          470|     if m ? config || m ? options then
             |     ^
          471|       let badAttrs = removeAttrs m ["_class" "_file" "key" "disabledModules" "imports" "options" "config" "meta" "freeformType"]; in

       … in the left operand of the OR (||) operator
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:470:19:
          469|     in
          470|     if m ? config || m ? options then
             |                   ^
          471|       let badAttrs = removeAttrs m ["_class" "_file" "key" "disabledModules" "imports" "options" "config" "meta" "freeformType"]; in

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:361:59:
          360|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          361|         else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
             |                                                           ^
          362|

       … while calling 'applyModuleArgsIfFunction'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:495:39:
          494|
          495|   applyModuleArgsIfFunction = key: f: args@{ config, ... }:
             |                                       ^
          496|     if isFunction f then applyModuleArgs key f args else f;

       … while evaluating a branch condition
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:496:5:
          495|   applyModuleArgsIfFunction = key: f: args@{ config, ... }:
          496|     if isFunction f then applyModuleArgs key f args else f;
             |     ^
          497|

       … from call site
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:496:8:
          495|   applyModuleArgsIfFunction = key: f: args@{ config, ... }:
          496|     if isFunction f then applyModuleArgs key f args else f;
             |        ^
          497|

       … while calling 'isFunction'
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/trivial.nix:1000:16:
          999|   */
         1000|   isFunction = f: builtins.isFunction f ||
             |                ^
         1001|     (f ? __functor && isFunction (f.__functor f));

       … in the left operand of the OR (||) operator
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/trivial.nix:1000:41:
          999|   */
         1000|   isFunction = f: builtins.isFunction f ||
             |                                         ^
         1001|     (f ? __functor && isFunction (f.__functor f));

       … while calling the 'isFunction' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/trivial.nix:1000:19:
          999|   */
         1000|   isFunction = f: builtins.isFunction f ||
             |                   ^
         1001|     (f ? __functor && isFunction (f.__functor f));

       … while calling the 'import' builtin
         at /nix/store/idq1bmwwy9rlkc21hccvx42wlwpxsx1f-source/lib/modules.nix:361:99:
          360|           throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
          361|         else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
             |                                                                                                   ^
          362|

       error: access to absolute path '/home' is forbidden in pure evaluation mode (use '--impure' to override)

I can run it as home-manager --impure switch but why should I have to? What has changed?

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.11.7, NixOS, 24.11 (Vicuna), 24.11beta708443.057f63b6dc1a`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.10`
 - channels(root): `"nixos-24.11"`
 - channels(cynic): `"nixos-unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`