Skip to content

Commit 2589af1

Browse files
committed
lib/modules: allow specifying system as an evalNixvim arg
1 parent 964b6d1 commit 2589af1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/modules.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,29 @@ 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+
# FIXME: what priority should this have?
44+
# If the user has set it as an evalNixvim arg _and_ a module option what behaviour would they expect?
45+
nixpkgs.hostPlatform = lib.mkOptionDefault { inherit system; };
46+
})
3747
];
3848
specialArgs = {
3949
inherit lib;

modules/top-level/nixpkgs.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ in
190190
apply = lib.systems.elaborate;
191191
defaultText = lib.literalMD ''
192192
Inherited from the "host" configuration's `pkgs`.
193-
Must be specified manually when building a standalone nixvim.
193+
Or the `evalNixvim`'s `system` argument.
194+
Otherwise, must be specified manually.
194195
'';
195196
description = ''
196197
Specifies the platform where the Nixvim configuration will run.

0 commit comments

Comments
 (0)