2024-01-25 14:49:57 +00:00
|
|
|
{ inputs
|
|
|
|
, lib
|
|
|
|
, config
|
|
|
|
|
|
|
|
, defaultOverlays
|
|
|
|
|
2024-01-28 03:44:39 +00:00
|
|
|
, ...
|
|
|
|
}:
|
2024-01-25 14:49:57 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.setups.nixvim;
|
2024-01-26 01:38:31 +00:00
|
|
|
nixvimModules = ../../nixvim;
|
2024-01-25 14:49:57 +00:00
|
|
|
|
2024-06-10 05:25:03 +00:00
|
|
|
mkNixvimConfig = { system, pkgs, nixvimBranch ? "nixvim", modules ? [ ] }:
|
|
|
|
inputs.${nixvimBranch}.legacyPackages.${system}.makeNixvimWithModule {
|
2024-01-25 14:49:57 +00:00
|
|
|
inherit pkgs;
|
|
|
|
module = {
|
|
|
|
imports = modules;
|
|
|
|
};
|
2024-01-26 01:38:31 +00:00
|
|
|
extraSpecialArgs = {
|
|
|
|
foodogsquaredModulesPath = builtins.toString nixvimModules;
|
|
|
|
};
|
2024-01-25 14:49:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
modulesOption = lib.mkOption {
|
2024-03-27 08:34:51 +00:00
|
|
|
type = with lib.types; listOf deferredModule;
|
2024-02-02 04:40:16 +00:00
|
|
|
default = [ ];
|
2024-01-25 14:49:57 +00:00
|
|
|
};
|
|
|
|
modulesOption' = configEnv: modulesOption // {
|
|
|
|
description = ''
|
|
|
|
A list of NixVim modules to be applied across all NixVim configurations
|
|
|
|
when imported as part of ${configEnv}.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
configType = { name, lib, config, ... }: {
|
|
|
|
options = {
|
|
|
|
nixpkgsBranches = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
|
|
|
description = ''
|
|
|
|
A list of nixpkgs branches for the NixVim configuration to be built
|
|
|
|
against.
|
|
|
|
'';
|
|
|
|
example = [
|
|
|
|
"nixos-unstable"
|
|
|
|
"nixos-stable"
|
|
|
|
];
|
|
|
|
};
|
2024-01-28 03:44:39 +00:00
|
|
|
|
2024-06-10 05:25:03 +00:00
|
|
|
nixvimBranch = lib.mkOption {
|
|
|
|
type = lib.types.nonEmptyStr;
|
|
|
|
default = "nixvim";
|
|
|
|
example = "nixvim-unstable";
|
|
|
|
description = ''
|
|
|
|
The NixVim branch to be used for the configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-28 03:44:39 +00:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
2024-01-25 14:49:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
modules = [
|
2024-02-14 13:14:06 +00:00
|
|
|
../../../configs/nixvim/${config.configName}
|
2024-01-25 14:49:57 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.setups.nixvim = {
|
|
|
|
configs = lib.mkOption {
|
2024-01-26 13:12:22 +00:00
|
|
|
type = with lib.types; attrsOf (submoduleWith {
|
|
|
|
specialArgs = { inherit (config) systems; };
|
|
|
|
modules = [
|
|
|
|
./shared/config-options.nix
|
|
|
|
configType
|
|
|
|
];
|
|
|
|
});
|
2024-02-02 04:40:16 +00:00
|
|
|
default = { };
|
2024-01-25 14:49:57 +00:00
|
|
|
description = ''
|
|
|
|
A set of NixVim configurations to be integrated into the declarative
|
|
|
|
setups configuration. Each of them will be available as part of
|
|
|
|
`nixvimConfigurations`.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
sharedModules = modulesOption // {
|
|
|
|
description = ''
|
|
|
|
A list of NixVim modules to be shared across all of the NixVim
|
|
|
|
configurations.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
standaloneConfigModules = modulesOption' "standalone configuration";
|
|
|
|
};
|
|
|
|
|
2024-02-02 04:40:16 +00:00
|
|
|
config = lib.mkIf (cfg.configs != { }) {
|
2024-02-11 07:16:25 +00:00
|
|
|
setups.nixvim.sharedModules = [
|
|
|
|
nixvimModules
|
2024-03-03 23:44:10 +00:00
|
|
|
|
|
|
|
# Import our private modules.
|
|
|
|
../../nixvim/_private
|
2024-02-11 07:16:25 +00:00
|
|
|
];
|
2024-01-26 01:38:31 +00:00
|
|
|
|
2024-01-25 14:49:57 +00:00
|
|
|
perSystem = { system, config, lib, ... }:
|
|
|
|
(
|
|
|
|
let
|
|
|
|
validConfigs = lib.filterAttrs
|
2024-02-02 04:40:16 +00:00
|
|
|
(_: metadata: lib.elem system metadata.systems)
|
|
|
|
cfg.configs;
|
2024-01-25 14:49:57 +00:00
|
|
|
|
|
|
|
nixvimConfigurations =
|
|
|
|
let
|
|
|
|
generateNixvimConfigs = name: metadata:
|
|
|
|
let
|
2024-01-28 03:44:39 +00:00
|
|
|
iterateThruBranches = nixpkgsBranch:
|
|
|
|
let
|
|
|
|
pkgs = import inputs.${nixpkgsBranch} {
|
|
|
|
inherit system;
|
|
|
|
overlays = defaultOverlays ++ [
|
|
|
|
inputs.neovim-nightly-overlay.overlays.default
|
|
|
|
];
|
|
|
|
config.allowUnfree = true;
|
|
|
|
};
|
|
|
|
|
2024-05-26 08:38:22 +00:00
|
|
|
# Unfortunately we cannot have NixVim with Neovim-reliant
|
|
|
|
# packages such as Neovide or something similar. It has
|
|
|
|
# to be Neovim.
|
2024-01-28 03:44:39 +00:00
|
|
|
neovimPackages = metadata.neovimPackages pkgs;
|
|
|
|
|
|
|
|
mkNixvimConfig' = neovimPkg:
|
|
|
|
lib.nameValuePair
|
|
|
|
"${name}-${nixpkgsBranch}-${neovimPkg.name}"
|
|
|
|
(mkNixvimConfig {
|
|
|
|
inherit system pkgs;
|
2024-06-10 05:25:03 +00:00
|
|
|
inherit (metadata) nixvimBranch;
|
2024-01-28 03:44:39 +00:00
|
|
|
modules =
|
|
|
|
cfg.sharedModules
|
|
|
|
++ cfg.standaloneConfigModules
|
|
|
|
++ metadata.modules
|
2024-02-02 04:40:16 +00:00
|
|
|
++ [{ package = neovimPkg; }];
|
2024-01-28 03:44:39 +00:00
|
|
|
});
|
|
|
|
in
|
|
|
|
builtins.map mkNixvimConfig' neovimPackages;
|
|
|
|
|
|
|
|
nixvimConfigs = lib.lists.flatten
|
|
|
|
(builtins.map iterateThruBranches metadata.nixpkgsBranches);
|
2024-01-25 14:49:57 +00:00
|
|
|
in
|
|
|
|
lib.listToAttrs nixvimConfigs;
|
|
|
|
in
|
|
|
|
lib.concatMapAttrs generateNixvimConfigs validConfigs;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
# We'll reuse these.
|
|
|
|
inherit nixvimConfigurations;
|
|
|
|
|
|
|
|
checks =
|
|
|
|
lib.mapAttrs'
|
|
|
|
(name: nvim:
|
|
|
|
lib.nameValuePair
|
|
|
|
"nixvim-check-${name}"
|
|
|
|
(inputs.nixvim.lib.${system}.check.mkTestDerivationFromNvim {
|
2024-02-02 04:40:16 +00:00
|
|
|
inherit nvim;
|
|
|
|
name = "${name} configuration";
|
2024-01-25 14:49:57 +00:00
|
|
|
}))
|
|
|
|
nixvimConfigurations;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|