Skip to content

Commit 1d91902

Browse files
committed
lib/modules: allow specifying system as an evalNixvim arg
1 parent a4d7b87 commit 1d91902

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

flake-modules/legacy-packages.nix

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
{
33
perSystem =
44
{
5-
pkgs,
6-
lib,
75
makeNixvimWithModule,
6+
system,
87
...
98
}:
109
{
@@ -13,12 +12,7 @@
1312
makeNixvim = module: makeNixvimWithModule { inherit module; };
1413

1514
nixvimConfiguration = helpers.modules.evalNixvim {
16-
modules = [
17-
{
18-
_file = ./legacy-packages.nix;
19-
nixpkgs.pkgs = lib.mkDefault pkgs;
20-
}
21-
];
15+
inherit system;
2216
};
2317
};
2418
};

lib/modules.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,27 @@ in
2121
{
2222
modules ? [ ],
2323
extraSpecialArgs ? { },
24+
system ? null, # Can also be defined using the `nixpkgs.hostPlatform` option
2425
}:
2526
# Ensure a suitable `lib` is used
2627
# TODO: offer a lib overlay that end-users could use to apply nixvim's extensions to their own `lib`
2728
assert lib.assertMsg (extraSpecialArgs ? lib -> extraSpecialArgs.lib ? nixvim) ''
2829
Nixvim requires a lib that includes some custom extensions, however the `lib` from `specialArgs` does not have a `nixvim` attr.
2930
Remove `lib` from nixvim's `specialArgs` or ensure you apply nixvim's extensions to your `lib`.'';
31+
assert lib.assertMsg (system != null -> lib.isString system) ''
32+
When `system` is supplied to `evalNixvim`, it must be a string.
33+
To define a more complex system, please use nixvim's `nixpkgs.hostPlatform` option.'';
3034
lib.evalModules {
3135
modules = modules ++ [
3236
../modules/top-level
3337
{
3438
_file = "<nixvim-flake>";
3539
flake = lib.mkOptionDefault flake;
3640
}
41+
(lib.optionalAttrs (lib.isString system) {
42+
_file = "evalNixvim";
43+
nixpkgs.hostPlatform = lib.mkOptionDefault { inherit system; };
44+
})
3745
];
3846
specialArgs = {
3947
inherit lib;

modules/top-level/nixpkgs.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ in
164164
apply = lib.systems.elaborate;
165165
defaultText = lib.literalMD ''
166166
- Inherited from the "host" configuration's `pkgs`
167-
- Must be specified manually when building a standalone nixvim
167+
- Or `evalNixvim`'s `system` argument
168+
- Otherwise, must be specified manually
168169
'';
169170
description = ''
170171
Specifies the platform where the Nixvim configuration will run.

0 commit comments

Comments
 (0)