File tree Expand file tree Collapse file tree 12 files changed +59
-47
lines changed Expand file tree Collapse file tree 12 files changed +59
-47
lines changed Original file line number Diff line number Diff line change 7
7
# We overlay a few tweaks into pkgs, for use in the docs
8
8
pkgs = import ./pkgs.nix { inherit system nixpkgs ; } ;
9
9
inherit ( pkgs ) lib ;
10
- helpers = import ../lib { inherit lib ; } ;
10
+ helpers = import ../lib {
11
+ inherit lib ;
12
+ pkgsPath = nixpkgs ;
13
+ } ;
11
14
12
15
nixvimPath = toString ./.. ;
13
16
34
37
} ;
35
38
36
39
evaledModules = helpers . modules . evalNixvim {
37
- extraSpecialArgs = {
38
- defaultPkgs = pkgs ;
39
- } ;
40
40
modules = [
41
41
{ isDocs = true ; }
42
42
{ nixpkgs . pkgs = lib . mkDefault pkgs ; }
Original file line number Diff line number Diff line change 16
16
modules = [
17
17
{ nixpkgs . pkgs = lib . mkDefault pkgs ; }
18
18
] ;
19
- extraSpecialArgs = {
20
- defaultPkgs = pkgs ;
21
- } ;
22
19
check = false ;
23
20
} ;
24
21
} ;
Original file line number Diff line number Diff line change 1
1
{
2
2
config ,
3
+ inputs ,
3
4
lib ,
4
5
withSystem ,
5
6
...
13
14
{ pkgs , ... } :
14
15
{
15
16
# NOTE: this is the publicly documented flake output we've had for a while
16
- check = import ../lib/tests.nix { inherit lib pkgs ; } ;
17
+ check = import ../lib/tests.nix {
18
+ inherit lib pkgs ;
19
+ pkgsPath = inputs . nixpkgs ;
20
+ } ;
17
21
# NOTE: user-facing so we must include the legacy `pkgs` argument
18
- helpers = import ../lib { inherit lib pkgs ; } ;
22
+ helpers = import ../lib {
23
+ inherit lib pkgs ;
24
+ pkgsPath = inputs . nixpkgs ;
25
+ } ;
19
26
}
20
27
)
21
28
) ;
Original file line number Diff line number Diff line change 1
1
{
2
2
pkgs ? null ,
3
+ # `pkgsPath` is required for evalNixvim's default specialArgs
4
+ pkgsPath ? pkgs . path or null ,
3
5
lib ? pkgs . lib ,
4
6
_nixvimTests ? false ,
5
7
...
@@ -38,24 +40,12 @@ lib.fix (
38
40
extendedLib = call ./extend-lib.nix { inherit lib ; } ;
39
41
keymaps = call ./keymap-helpers.nix { } ;
40
42
lua = call ./to-lua.nix { } ;
43
+ modules = call ./modules.nix { inherit pkgsPath ; } ;
41
44
neovim-plugin = call ./neovim-plugin.nix { } ;
42
45
options = call ./options.nix { } ;
43
46
utils = call ./utils.nix { inherit _nixvimTests ; } ;
44
47
vim-plugin = call ./vim-plugin.nix { } ;
45
48
46
- # Handle modules, which currently requires a `defaultPkgs` specialArg
47
- # FIXME: our minimal specialArgs should not need `pkgs`
48
- modules = call ./modules.nix { } // {
49
- # Minimal specialArgs required to evaluate nixvim modules
50
- specialArgs = self . modules . specialArgsWith {
51
- defaultPkgs =
52
- if pkgs == null then
53
- throw "`modules.specialArgs` cannot currently be used when nixvim's lib is built without a `pkgs` instance. This will be resolved in the future."
54
- else
55
- pkgs ;
56
- } ;
57
- } ;
58
-
59
49
# Handle builders, which has some deprecated stuff that depends on `pkgs`
60
50
builders = builders // deprecatedBuilders ;
61
51
inherit ( self . builders )
Original file line number Diff line number Diff line change 1
1
{
2
2
lib ,
3
3
self ,
4
+ pkgsPath ,
4
5
} :
5
6
rec {
7
+ # Minimal specialArgs required to evaluate nixvim modules
8
+ specialArgs = self . modules . specialArgsWith { } ;
9
+
6
10
# Build specialArgs for evaluating nixvim modules
7
11
specialArgsWith =
8
- # TODO: switch defaultPkgs -> pkgsPath (i.e. pkgs.path or inputs.nixvim)
9
- # FIXME: Ideally, we should not require callers to pass in _anything_ specific
10
- { defaultPkgs , ... } @extraSpecialArgs :
12
+ extraSpecialArgs :
11
13
{
12
- inherit lib defaultPkgs ;
14
+ inherit lib ;
15
+ # TODO: find a better way to handle pkgsPath 🤔
16
+ # - Maybe nixvim's lib should always be provided with `pkgsPath`?
17
+ # - Or maybe it can evaluate it internally, by reading `flake.lock`?
18
+ pkgsPath =
19
+ if pkgsPath == null then
20
+ throw ''
21
+ `modules.specialArgs` or `modules.evalNixvim` was used without a `pkgsPath`.
22
+ You can resolve this by either specifying `pkgsPath` using `extraSpecialArgs` or `modules.specialArgsWith`,
23
+ or by using a nixvim lib instance evaluated with `pkgsPath` supplied.
24
+ ''
25
+ else
26
+ builtins . toString pkgsPath ;
13
27
# TODO: deprecate `helpers`
14
28
helpers = self ;
15
29
}
Original file line number Diff line number Diff line change 1
1
{
2
2
pkgs ,
3
+ pkgsPath ? pkgs . path ,
3
4
lib ? pkgs . lib ,
4
5
...
5
6
} :
46
47
let
47
48
helpers = import ../lib {
48
49
# NOTE: must match the user-facing functions, so we still include the `pkgs` argument
49
- inherit pkgs lib ;
50
+ inherit pkgs pkgsPath lib ;
50
51
# TODO: deprecate helpers.enableExceptInTests,
51
52
# add a context option e.g. `config.isTest`?
52
53
_nixvimTests = true ;
65
66
# FIXME: don't do this by default
66
67
{ nixpkgs . pkgs = lib . mkDefault pkgs ; }
67
68
] ;
68
- extraSpecialArgs = {
69
- defaultPkgs = pkgs ;
70
- } // extraSpecialArgs ;
69
+ inherit extraSpecialArgs ;
71
70
# Don't check assertions/warnings while evaluating nixvim config
72
71
# We'll let the test derivation handle that
73
72
check = false ;
Original file line number Diff line number Diff line change 1
- { defaultPkgs , ... } :
2
- let
3
- # We can't use config._module.args to define imports,
4
- # so we're forced to use specialArgs.defaultPkgs's path
5
- nixosModules = defaultPkgs . path + "/nixos/modules/" ;
6
- in
1
+ { pkgsPath , ... } :
7
2
{
8
3
imports = [
9
4
./context.nix
10
5
./nixvim-info.nix
11
- ( nixosModules + "/misc/assertions.nix" )
12
- ( nixosModules + "/misc/meta.nix" )
6
+ # FIXME: this is the only reason `pkgsPath` needs to be a specialArg.
7
+ # It also fails when `pkgsPath` is a string with context because meta.nix
8
+ # tries to use the _file string somewhere that string-context isn't supported 😭
9
+ ( pkgsPath + "/nixos/modules/misc/assertions.nix" )
10
+ ( builtins . unsafeDiscardStringContext pkgsPath + "/nixos/modules/misc/meta.nix" )
13
11
] ;
14
12
}
Original file line number Diff line number Diff line change 1
1
{
2
+ # This flake
3
+ flake ,
2
4
# Option path where extraFiles should go
3
5
filesOpt ? null ,
4
6
# Filepath prefix to apply to extraFiles
47
49
{
48
50
# Make our lib available to the host modules
49
51
# NOTE: user-facing so we must include the legacy `pkgs` argument
50
- lib . nixvim = lib . mkDefault ( import ../lib { inherit pkgs lib ; } ) ;
52
+ lib . nixvim = lib . mkDefault (
53
+ import ../lib {
54
+ inherit pkgs lib ;
55
+ pkgsPath = flake . inputs . nixpkgs ;
56
+ }
57
+ ) ;
51
58
52
59
# Make nixvim's "extended" lib available to the host's module args
53
60
_module . args . nixvimLib = lib . mkDefault config . lib . nixvim . extendedLib ;
Original file line number Diff line number Diff line change 26
26
type = types . submoduleWith {
27
27
shorthandOnlyDefinesConfig = true ;
28
28
specialArgs = config . lib . nixvim . modules . specialArgsWith {
29
- defaultPkgs = pkgs ;
30
29
darwinConfig = config ;
31
30
} ;
32
31
modules = [
39
38
} ;
40
39
} ;
41
40
42
- imports = [ ( import ./_shared.nix { } ) ] ;
41
+ imports = [ ( import ./_shared.nix { inherit flake ; } ) ] ;
43
42
44
43
config = mkIf cfg . enable ( mkMerge [
45
44
{
Original file line number Diff line number Diff line change 25
25
type = types . submoduleWith {
26
26
shorthandOnlyDefinesConfig = true ;
27
27
specialArgs = config . lib . nixvim . modules . specialArgsWith {
28
- defaultPkgs = pkgs ;
29
28
hmConfig = config ;
30
29
} ;
31
30
modules = [
40
39
41
40
imports = [
42
41
( import ./_shared.nix {
42
+ inherit flake ;
43
43
filesOpt = [
44
44
"xdg"
45
45
"configFile"
You can’t perform that action at this time.
0 commit comments