flake-parts/setups/nixvim: add neovimPackages option

This commit is contained in:
Gabriel Arazas 2024-01-28 11:44:39 +08:00
parent 523f64b794
commit ee285c2004
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC

View File

@ -4,20 +4,14 @@
, defaultOverlays
, ... }:
, ...
}:
let
cfg = config.setups.nixvim;
partsConfig = config;
nixvimModules = ../../nixvim;
mkNixvimConfig = { system, nixpkgsBranch, modules ? [] }:
let
pkgs = import inputs.${nixpkgsBranch} {
inherit system;
config.allowUnfree = true;
};
in
mkNixvimConfig = { system, pkgs, modules ? [] }:
inputs.nixvim.legacyPackages.${system}.makeNixvimWithModule {
inherit pkgs;
module = {
@ -52,6 +46,25 @@ let
"nixos-stable"
];
};
neovimPackages = lib.mkOption {
type = with lib.types; functionTo (listOf package);
default = pkgs: with pkgs; [ neovim ];
defaultText = "pkgs: with pkgs; [ neovim ]";
example = lib.literalExpression ''
pkgs: with pkgs; [
(wrapNeovim neovim-unwrapped { })
neovim-nightly
neovide
]
'';
description = ''
A list of Neovim packages from different branches to be built
against. Since this is to be used per-system, it should be a function
that returns a list of packages where the given statement is the
nixpkgs instance.
'';
};
};
config = {
@ -101,18 +114,34 @@ in
let
generateNixvimConfigs = name: metadata:
let
mkNixvim = nixpkgsBranch:
iterateThruBranches = nixpkgsBranch:
let
pkgs = import inputs.${nixpkgsBranch} {
inherit system;
overlays = defaultOverlays ++ [
inputs.neovim-nightly-overlay.overlays.default
];
config.allowUnfree = true;
};
neovimPackages = metadata.neovimPackages pkgs;
mkNixvimConfig' = neovimPkg:
lib.nameValuePair
"${name}-${nixpkgsBranch}"
"${name}-${nixpkgsBranch}-${neovimPkg.name}"
(mkNixvimConfig {
inherit system nixpkgsBranch;
inherit system pkgs;
modules =
cfg.sharedModules
++ cfg.standaloneConfigModules
++ metadata.modules;
++ metadata.modules
++ [ { package = neovimPkg; } ];
});
in
builtins.map mkNixvimConfig' neovimPackages;
nixvimConfigs = builtins.map mkNixvim metadata.nixpkgsBranches;
nixvimConfigs = lib.lists.flatten
(builtins.map iterateThruBranches metadata.nixpkgsBranches);
in
lib.listToAttrs nixvimConfigs;
in