Skip to content

Commit

Permalink
lib/modules: allow specifying system as an evalNixvim arg
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Dec 23, 2024
1 parent 964b6d1 commit 2589af1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@ in
{
modules ? [ ],
extraSpecialArgs ? { },
system ? null, # Can also be defined using the `nixpkgs.hostPlatform` option
}:
# Ensure a suitable `lib` is used
# TODO: offer a lib overlay that end-users could use to apply nixvim's extensions to their own `lib`
assert lib.assertMsg (extraSpecialArgs ? lib -> extraSpecialArgs.lib ? nixvim) ''
Nixvim requires a lib that includes some custom extensions, however the `lib` from `specialArgs` does not have a `nixvim` attr.
Remove `lib` from nixvim's `specialArgs` or ensure you apply nixvim's extensions to your `lib`.'';
assert lib.assertMsg (system != null -> lib.isString system) ''
When `system` is supplied to `evalNixvim`, it must be a string.
To define a more complex system, please use nixvim's `nixpkgs.hostPlatform` option.'';
lib.evalModules {
modules = modules ++ [
../modules/top-level
{
_file = "<nixvim-flake>";
flake = lib.mkOptionDefault flake;
}
(lib.optionalAttrs (lib.isString system) {
_file = "evalNixvim";
# FIXME: what priority should this have?
# If the user has set it as an evalNixvim arg _and_ a module option what behaviour would they expect?
nixpkgs.hostPlatform = lib.mkOptionDefault { inherit system; };
})
];
specialArgs = {
inherit lib;
Expand Down
3 changes: 2 additions & 1 deletion modules/top-level/nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ in
apply = lib.systems.elaborate;
defaultText = lib.literalMD ''
Inherited from the "host" configuration's `pkgs`.
Must be specified manually when building a standalone nixvim.
Or the `evalNixvim`'s `system` argument.
Otherwise, must be specified manually.
'';
description = ''
Specifies the platform where the Nixvim configuration will run.
Expand Down

0 comments on commit 2589af1

Please sign in to comment.