Skip to content

Commit acb3694

Browse files
committed
wrappers/standalone: make pkgs arg optional, allow specifying system
1 parent 2589af1 commit acb3694

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

flake-modules/wrappers.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
{ inputs, self, ... }:
1+
{
2+
inputs,
3+
self,
4+
lib,
5+
...
6+
}:
27
{
38
perSystem =
49
{ system, pkgs, ... }:
510
{
611
_module.args = {
7-
makeNixvimWithModule = import ../wrappers/standalone.nix pkgs self;
12+
makeNixvimWithModule = import ../wrappers/standalone.nix {
13+
inherit lib self;
14+
defaultSystem = system;
15+
};
816
};
917

1018
checks =

templates/simple/flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
];
1919

2020
perSystem =
21-
{ pkgs, system, ... }:
21+
{ system, ... }:
2222
let
2323
nixvimLib = nixvim.lib.${system};
2424
nixvim' = nixvim.legacyPackages.${system};
2525
nixvimModule = {
26-
inherit pkgs;
26+
inherit system; # or alternatively, set `pkgs`
2727
module = import ./config; # import the module directly
2828
# You can use `extraSpecialArgs` to pass additional arguments to your module files
2929
extraSpecialArgs = {

wrappers/standalone.nix

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
default_pkgs: self:
1+
{
2+
self,
3+
lib,
4+
defaultSystem,
5+
}:
26
{
37
# TODO: Deprecate this arg in favour of using module options
4-
pkgs ? default_pkgs,
5-
lib ? pkgs.lib,
8+
pkgs ? null,
9+
# NOTE: `defaultSystem` is the only reason this function can't go in `<nixvim>.lib`
10+
system ? defaultSystem,
611
extraSpecialArgs ? { },
712
_nixvimTests ? false,
813
module,
@@ -12,23 +17,32 @@ let
1217
helpers = self.lib.nixvim.override { inherit _nixvimTests; };
1318
inherit (helpers.modules) evalNixvim;
1419

20+
systemMod =
21+
if pkgs == null then
22+
{
23+
_file = ./standalone.nix;
24+
nixpkgs.hostPlatform = lib.mkDefault { inherit system; };
25+
}
26+
else
27+
{
28+
_file = ./standalone.nix;
29+
nixpkgs.pkgs = lib.mkDefault pkgs;
30+
};
31+
1532
mkNvim =
1633
mod:
1734
let
1835
nixvimConfig = evalNixvim {
1936
modules = [
2037
mod
21-
# TODO: only include this when `args?pkgs`:
22-
{
23-
_file = ./standalone.nix;
24-
nixpkgs.pkgs = lib.mkDefault pkgs;
25-
}
38+
systemMod
2639
];
2740
inherit extraSpecialArgs;
2841
};
2942
inherit (nixvimConfig.config) enableMan build;
43+
inherit (nixvimConfig._module.args.pkgs) symlinkJoin;
3044
in
31-
(pkgs.symlinkJoin {
45+
(symlinkJoin {
3246
name = "nixvim";
3347
paths = [
3448
build.package

0 commit comments

Comments
 (0)