|
57 | 57 | }; |
58 | 58 | }; |
59 | 59 |
|
60 | | - config = { |
61 | | - # For now we only set this when `nixpkgs.pkgs` is defined |
62 | | - # TODO: construct a default pkgs instance from pkgsPath and cfg options |
63 | | - # https://github.com/nix-community/nixvim/issues/1784 |
64 | | - _module.args = lib.optionalAttrs opt.pkgs.isDefined { |
| 60 | + config = |
| 61 | + let |
| 62 | + # TODO: construct a default pkgs instance from pkgsPath and cfg options |
| 63 | + # https://github.com/nix-community/nixvim/issues/1784 |
| 64 | + |
| 65 | + finalPkgs = |
| 66 | + if opt.pkgs.isDefined then |
| 67 | + cfg.pkgs |
| 68 | + else |
| 69 | + # TODO: Remove once pkgs can be constructed internally |
| 70 | + throw '' |
| 71 | + nixvim: `nixpkgs.pkgs` is not defined. In the future, this option will be optional. |
| 72 | + Currently a pkgs instance must be evaluated externally and assigned to `nixpkgs.pkgs` option. |
| 73 | + ''; |
| 74 | + in |
| 75 | + { |
65 | 76 | # We explicitly set the default override priority, so that we do not need |
66 | 77 | # to evaluate finalPkgs in case an override is placed on `_module.args.pkgs`. |
67 | 78 | # After all, to determine a definition priority, we need to evaluate `._type`, |
68 | 79 | # which is somewhat costly for Nixpkgs. With an explicit priority, we only |
69 | 80 | # evaluate the wrapper to find out that the priority is lower, and then we |
70 | 81 | # don't need to evaluate `finalPkgs`. |
71 | | - pkgs = lib.mkOverride lib.modules.defaultOverridePriority cfg.pkgs.__splicedPackages; |
| 82 | + _module.args.pkgs = lib.mkOverride lib.modules.defaultOverridePriority finalPkgs.__splicedPackages; |
72 | 83 | }; |
73 | | - |
74 | | - assertions = [ |
75 | | - { |
76 | | - # TODO: Remove or rephrase once pkgs can be constructed internally |
77 | | - assertion = config._module.args ? pkgs; |
78 | | - message = '' |
79 | | - `nixpkgs.pkgs` is not defined. In the future, this option will be optional. |
80 | | - Currently a pkgs instance must be evaluated externally and assigned to `nixpkgs.pkgs` option. |
81 | | - ''; |
82 | | - } |
83 | | - ]; |
84 | | - }; |
85 | 84 | } |
0 commit comments