snowfallorg / lib

Unified configuration for systems, packages, modules, shells, templates, and more with Nix Flakes.
https://snowfall.org
Other
417 stars 37 forks source link

Issue migrating to v2, cannot find lib inside of system configuration file #31

Closed dukeofcool199 closed 11 months ago

dukeofcool199 commented 11 months ago

I recently attempted to upgrade to snowfall-lib v2, but now when I try to build my systems I am met with the following error.

building the system configuration...
warning: Git tree '/home/jenkin/workspace/nix-configs' is dirty
error:
       … while calling the 'seq' builtin

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:326:18:

          325|         options = checked options;
          326|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          327|         _module = checked (config._module);

       … while calling the 'throw' builtin

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:302:18:

          301|                     ''
          302|             else throw baseMsg
             |                  ^
          303|         else null;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: undefined variable 'enabled'

       at /nix/store/cc0c9nkgbvcbqgjzy6p68bvaj59md64i-22943hsd1bwsj4v1adilh6k1206h63a9-source/systems/x86_64-linux/jenktop/default.nix:60:16:

           59|     apps = {
           60|       ardour = enabled;
             |                ^
           61|       obs = enabled;

I took a look at the migration guide, And I am not using anything that would have needed changing that was stated in the migration guide

here is a link to my configuration repo.

https://github.com/dukeofcool199/config/tree/master

any help would be greatly appreciated

osv commented 11 months ago

@dukeofcool199 You need move "modules/*" to "modules/nixos" I think this is not described in migration doc. And do rest of tasks described in migration doc.

jakehamilton commented 11 months ago

@dukeofcool199 would you be able to push the broken version up to a different branch? I can take a look and see what's going wrong. The migration guide is likely missing some things.

dukeofcool199 commented 11 months ago

@jakehamilton

https://github.com/dukeofcool199/config/tree/borked/attempt-to-migrate-to-v2

this branch has the snowfall-lib flake input updated to v2 and running flake build-system jenktop will showcase the issue

your initial response is much appreciated


I did what was suggested by @osv and I think it is putting me further in the right direction. Now i am getting the following error instead

it is stating that I cannot find one of my lib functions (which i shamelessly copied from @jakehamilton 's config long long ago) in one of my nixos modules.

flake build-system jenktop --show-trace                            ──(Thu,Dec07)─┘
building the system configuration...
warning: Git tree '/home/jenkin/workspace/nix-configs' is dirty
error:
       … while calling the 'seq' builtin

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:326:18:

          325|         options = checked options;
          326|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          327|         _module = checked (config._module);

       … while evaluating a branch condition

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:267:9:

          266|       checkUnmatched =
          267|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |         ^
          268|           let

       … in the right operand of the AND (&&) operator

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:267:72:

          266|       checkUnmatched =
          267|         if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
             |                                                                        ^
          268|           let

       … while evaluating the attribute 'unmatchedDefns'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:671:7:

          670|       # Transforms unmatchedDefnsByName into a list of definitions
          671|       unmatchedDefns =
             |       ^
          672|         if configs == []

       … while calling the 'concatLists' builtin

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:678:11:

          677|         else
          678|           concatLists (mapAttrsToList (name: defs:
             |           ^
          679|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:539:10:

          538|     attrs:
          539|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          540|

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:539:16:

          538|     attrs:
          539|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          540|

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:678:46:

          677|         else
          678|           concatLists (mapAttrsToList (name: defs:
             |                                              ^
          679|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:664:22:

          663|         # Propagate all unmatched definitions from nested option sets
          664|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          665|         # Plus the definitions for the current prefix that don't have a matching option

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:539:10:

          538|     attrs:
          539|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          540|

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:539:16:

          538|     attrs:
          539|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          540|

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:678:46:

          677|         else
          678|           concatLists (mapAttrsToList (name: defs:
             |                                              ^
          679|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:664:22:

          663|         # Propagate all unmatched definitions from nested option sets
          664|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          665|         # Plus the definitions for the current prefix that don't have a matching option

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:539:10:

          538|     attrs:
          539|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          540|

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:539:16:

          538|     attrs:
          539|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          540|

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:678:46:

          677|         else
          678|           concatLists (mapAttrsToList (name: defs:
             |                                              ^
          679|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:664:22:

          663|         # Propagate all unmatched definitions from nested option sets
          664|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          665|         # Plus the definitions for the current prefix that don't have a matching option

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:539:10:

          538|     attrs:
          539|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          540|

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:539:16:

          538|     attrs:
          539|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          540|

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:678:46:

          677|         else
          678|           concatLists (mapAttrsToList (name: defs:
             |                                              ^
          679|             map (def: def // {

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:664:22:

          663|         # Propagate all unmatched definitions from nested option sets
          664|         mapAttrs (n: v: v.unmatchedDefns) resultsByName
             |                      ^
          665|         # Plus the definitions for the current prefix that don't have a matching option

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:594:46:

          593|       # an attrset 'name' => list of submodules that define ‘name’.
          594|       defnsByName = byName "config" (module: value:
             |                                              ^
          595|           map (config: { inherit (module) file; inherit config; }) (pushDownProperties value)

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:595:69:

          594|       defnsByName = byName "config" (module: value:
          595|           map (config: { inherit (module) file; inherit config; }) (pushDownProperties value)
             |                                                                     ^
          596|         ) configs;

       … while calling 'pushDownProperties'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:826:24:

          825|   */
          826|   pushDownProperties = cfg:
             |                        ^
          827|     if cfg._type or "" == "merge" then

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:830:52:

          829|     else if cfg._type or "" == "if" then
          830|       map (mapAttrs (n: v: mkIf cfg.condition v)) (pushDownProperties cfg.content)
             |                                                    ^
          831|     else if cfg._type or "" == "override" then

       … while calling 'pushDownProperties'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:826:24:

          825|   */
          826|   pushDownProperties = cfg:
             |                        ^
          827|     if cfg._type or "" == "merge" then

       … while calling 'pushDownProperties'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:826:24:

          825|   */
          826|   pushDownProperties = cfg:
             |                        ^
          827|     if cfg._type or "" == "merge" then

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/nixos/modules/tasks/network-interfaces-systemd.nix:89:32:

           88|
           89|   interfaceNetworks = mkMerge (forEach interfaces (i: {
             |                                ^
           90|     netdevs = mkIf i.virtual ({

       … while calling 'forEach'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/lists.nix:36:17:

           35|   */
           36|   forEach = xs: f: map f xs;
             |                 ^
           37|

       … while calling 'g'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:595:19:

          594|           g =
          595|             name: value:
             |                   ^
          596|             if isAttrs value && cond value

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:598:20:

          597|               then recurse (path ++ [name]) value
          598|               else f (path ++ [name]) value;
             |                    ^
          599|         in mapAttrs g;

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:248:72:

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

       … while evaluating the option `networking.interfaces':

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:774:28:

          773|         # Process mkMerge and mkIf properties.
          774|         defs' = concatMap (m:
             |                            ^
          775|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/nixos/modules/virtualisation/virtualbox-host.nix':

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:775:137:

          774|         defs' = concatMap (m:
          775|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          776|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:846:25:

          845|   */
          846|   dischargeProperties = def:
             |                         ^
          847|     if def._type or "" == "merge" then

       … while calling 'g'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:595:19:

          594|           g =
          595|             name: value:
             |                   ^
          596|             if isAttrs value && cond value

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:598:20:

          597|               then recurse (path ++ [name]) value
          598|               else f (path ++ [name]) value;
             |                    ^
          599|         in mapAttrs g;

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:248:72:

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

       … while evaluating the option `virtualisation.virtualbox.host.enable':

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:774:28:

          773|         # Process mkMerge and mkIf properties.
          774|         defs' = concatMap (m:
             |                            ^
          775|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/s9zkyzvg1srd9zavffh8m8v4pc9njiyy-j9al5a1vqsy30qpqalpfj1bs1s1b2yww-source/modules/nixos/services/virtualisation/default.nix':

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:775:137:

          774|         defs' = concatMap (m:
          775|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          776|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:846:25:

          845|   */
          846|   dischargeProperties = def:
             |                         ^
          847|     if def._type or "" == "merge" then

       … while calling 'g'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/attrsets.nix:595:19:

          594|           g =
          595|             name: value:
             |                   ^
          596|             if isAttrs value && cond value

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:659:37:

          658|
          659|       matchedOptions = mapAttrs (n: v: v.matchedOptions) resultsByName;
             |                                     ^
          660|

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:618:39:

          617|
          618|       resultsByName = mapAttrs (name: decls:
             |                                       ^
          619|         # We're descending into attribute ‘name’.

       … while calling anonymous lambda

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:624:33:

          623|           defns' = defnsByName'.${name} or [];
          624|           optionDecls = filter (m: isOption m.options) decls;
             |                                 ^
          625|         in

       … from call site

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/modules.nix:624:36:

          623|           defns' = defnsByName'.${name} or [];
          624|           optionDecls = filter (m: isOption m.options) decls;
             |                                    ^
          625|         in

       … while calling 'isType'

         at /nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/lib/types.nix:70:18:

           69| rec {
           70|   isType = type: x: (x._type or "") == type;
             |                  ^
           71|

       error: undefined variable 'mkBoolOpt'

       at /nix/store/s9zkyzvg1srd9zavffh8m8v4pc9njiyy-j9al5a1vqsy30qpqalpfj1bs1s1b2yww-source/modules/nixos/services/virtualisation/default.nix:14:18:

           13|     vmware = mkBoolOpt false "enable vmware";
           14|     virtualbox = mkBoolOpt false "enable virtualbox";
             |                  ^
           15|     vagrant = mkBoolOpt false "enable vagrant";
jakehamilton commented 11 months ago

@dukeofcool199 it looks like enabled comes from your library here, but is not in scope when used because internal libraries are now namespaced. See the library quickstart for an example.

By default, the library will be namespaced under lib.internal. This can be changed by setting snowfall.namespace: https://snowfall.org/reference/lib/#snowfall-configuration

dukeofcool199 commented 11 months ago

I figured it out. Had to go into all my modules and update all lib and pkgs calls to match my flakes namespace.

@jakehamilton @osv thank you both for your help!

lol: this comment https://github.com/snowfallorg/lib/issues/31#issuecomment-1846308855 appeared just as I was typing this one out.