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 , defaultOverlays
, ... }: , ...
}:
let let
cfg = config.setups.nixvim; cfg = config.setups.nixvim;
partsConfig = config;
nixvimModules = ../../nixvim; nixvimModules = ../../nixvim;
mkNixvimConfig = { system, nixpkgsBranch, modules ? [] }: mkNixvimConfig = { system, pkgs, modules ? [] }:
let
pkgs = import inputs.${nixpkgsBranch} {
inherit system;
config.allowUnfree = true;
};
in
inputs.nixvim.legacyPackages.${system}.makeNixvimWithModule { inputs.nixvim.legacyPackages.${system}.makeNixvimWithModule {
inherit pkgs; inherit pkgs;
module = { module = {
@ -52,6 +46,25 @@ let
"nixos-stable" "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 = { config = {
@ -101,18 +114,34 @@ in
let let
generateNixvimConfigs = name: metadata: generateNixvimConfigs = name: metadata:
let 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 lib.nameValuePair
"${name}-${nixpkgsBranch}" "${name}-${nixpkgsBranch}-${neovimPkg.name}"
(mkNixvimConfig { (mkNixvimConfig {
inherit system nixpkgsBranch; inherit system pkgs;
modules = modules =
cfg.sharedModules cfg.sharedModules
++ cfg.standaloneConfigModules ++ 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 in
lib.listToAttrs nixvimConfigs; lib.listToAttrs nixvimConfigs;
in in