mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
modules/dependencies: init + add curl
This commit is contained in:
parent
33c3f98fdc
commit
cfd4b61262
11 changed files with 97 additions and 28 deletions
|
@ -40,6 +40,7 @@ lib.makeExtensible (
|
||||||
inherit (self.deprecation)
|
inherit (self.deprecation)
|
||||||
getOptionRecursive
|
getOptionRecursive
|
||||||
mkDeprecatedSubOptionModule
|
mkDeprecatedSubOptionModule
|
||||||
|
mkRemovedPackageOptionModule
|
||||||
mkSettingsRenamedOptionModules
|
mkSettingsRenamedOptionModules
|
||||||
transitionType
|
transitionType
|
||||||
;
|
;
|
||||||
|
|
|
@ -122,4 +122,16 @@ rec {
|
||||||
nestedTypes.coercedType = oldType;
|
nestedTypes.coercedType = oldType;
|
||||||
nestedTypes.finalType = newType;
|
nestedTypes.finalType = newType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mkRemovedPackageOptionModule =
|
||||||
|
{
|
||||||
|
plugin,
|
||||||
|
packageName,
|
||||||
|
oldPackageName ? packageName,
|
||||||
|
}:
|
||||||
|
lib.mkRemovedOptionModule [ "plugins" plugin "${oldPackageName}Package" ] ''
|
||||||
|
Please use the `dependencies.${packageName}` top-level option instead:
|
||||||
|
- `dependencies.${packageName}.enable = false` to disable installing `${packageName}`
|
||||||
|
- `dependencies.${packageName}.package` to choose which package to install for `${packageName}`.
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
./clipboard.nix
|
./clipboard.nix
|
||||||
./colorscheme.nix
|
./colorscheme.nix
|
||||||
./commands.nix
|
./commands.nix
|
||||||
|
./dependencies.nix
|
||||||
./diagnostics.nix
|
./diagnostics.nix
|
||||||
./doc.nix
|
./doc.nix
|
||||||
./editorconfig.nix
|
./editorconfig.nix
|
||||||
|
|
30
modules/dependencies.nix
Normal file
30
modules/dependencies.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.dependencies;
|
||||||
|
|
||||||
|
packages = {
|
||||||
|
curl.default = "curl";
|
||||||
|
};
|
||||||
|
|
||||||
|
mkDependencyOption = name: properties: {
|
||||||
|
enable = lib.mkEnableOption "Add ${name} to dependencies.";
|
||||||
|
|
||||||
|
package = lib.mkPackageOption pkgs name properties;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.dependencies = lib.mapAttrs mkDependencyOption packages;
|
||||||
|
|
||||||
|
config = {
|
||||||
|
extraPackages = lib.pipe cfg [
|
||||||
|
builtins.attrValues
|
||||||
|
(builtins.filter (p: p.enable))
|
||||||
|
(builtins.map (p: p.package))
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
helpers,
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
|
@ -12,13 +11,15 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
|
||||||
maintainers = [ maintainers.GaetanLepage ];
|
maintainers = [ maintainers.GaetanLepage ];
|
||||||
|
|
||||||
extraOptions = {
|
# TODO: added 2025-04-06, remove after 25.05
|
||||||
curlPackage = lib.mkPackageOption pkgs "curl" {
|
imports = [
|
||||||
nullable = true;
|
(lib.nixvim.mkRemovedPackageOptionModule {
|
||||||
};
|
plugin = "chatgpt";
|
||||||
};
|
packageName = "curl";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
extraConfig = cfg: { extraPackages = [ cfg.curlPackage ]; };
|
extraConfig = cfg: { dependencies.curl.enable = lib.mkDefault true; };
|
||||||
|
|
||||||
settingsOptions = {
|
settingsOptions = {
|
||||||
api_key_cmd = helpers.defaultNullOpts.mkStr null ''
|
api_key_cmd = helpers.defaultNullOpts.mkStr null ''
|
||||||
|
|
|
@ -14,7 +14,8 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
|
||||||
maintainers = [ lib.maintainers.GaetanLepage ];
|
maintainers = [ lib.maintainers.GaetanLepage ];
|
||||||
|
|
||||||
# TODO: Added 2025-03-20. Remove after 25.05
|
# TODO: option deprecations added 2025-03-20. Remove after 25.05
|
||||||
|
# TODO: curlPackage deprecation added 2025-04-06. Remove after 25.05
|
||||||
inherit (import ./deprecations.nix lib)
|
inherit (import ./deprecations.nix lib)
|
||||||
deprecateExtraOptions
|
deprecateExtraOptions
|
||||||
optionsRenamedToSettings
|
optionsRenamedToSettings
|
||||||
|
@ -22,10 +23,6 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
;
|
;
|
||||||
|
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
curlPackage = lib.mkPackageOption pkgs "curl" {
|
|
||||||
nullable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
ueberzugPackage = lib.mkOption {
|
ueberzugPackage = lib.mkOption {
|
||||||
type = with types; nullOr package;
|
type = with types; nullOr package;
|
||||||
default = pkgs.ueberzugpp;
|
default = pkgs.ueberzugpp;
|
||||||
|
@ -140,11 +137,10 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
extraPackages = [
|
# In theory, we could remove that if the user explicitly disables `downloadRemoteImages` for
|
||||||
# In theory, we could remove that if the user explicitly disables `downloadRemoteImages` for
|
# all integrations but shipping `curl` is not too heavy.
|
||||||
# all integrations but shipping `curl` is not too heavy.
|
dependencies.curl.enable = lib.mkDefault true;
|
||||||
cfg.curlPackage
|
|
||||||
|
|
||||||
] ++ lib.optional (cfg.settings.backend == "ueberzug") cfg.ueberzugPackage;
|
extraPackages = lib.optional (cfg.settings.backend == "ueberzug") cfg.ueberzugPackage;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,10 @@ lib: {
|
||||||
Nixvim(plugins.image): The option `integrations` has been renamed to `settings.integrations`.
|
Nixvim(plugins.image): The option `integrations` has been renamed to `settings.integrations`.
|
||||||
Warning: sub-options now have the same name as upstream (`clear_in_insert_mode`...).
|
Warning: sub-options now have the same name as upstream (`clear_in_insert_mode`...).
|
||||||
'')
|
'')
|
||||||
|
|
||||||
|
(lib.nixvim.mkRemovedPackageOptionModule {
|
||||||
|
plugin = "image";
|
||||||
|
packageName = "curl";
|
||||||
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
Refer to the documentation for more information.
|
Refer to the documentation for more information.
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TODO: added 2025-04-06: remove after 25.05
|
||||||
|
(lib.nixvim.mkRemovedPackageOptionModule {
|
||||||
|
plugin = "rest";
|
||||||
|
packageName = "curl";
|
||||||
|
})
|
||||||
]
|
]
|
||||||
++
|
++
|
||||||
map
|
map
|
||||||
|
@ -207,10 +213,6 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
};
|
};
|
||||||
|
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
curlPackage = lib.mkPackageOption pkgs "curl" {
|
|
||||||
nullable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
enableHttpFiletypeAssociation = lib.mkOption {
|
enableHttpFiletypeAssociation = lib.mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -300,7 +302,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
|
||||||
globals.rest_nvim = cfg.settings;
|
globals.rest_nvim = cfg.settings;
|
||||||
|
|
||||||
extraPackages = [ cfg.curlPackage ];
|
dependencies.curl.enable = lib.mkDefault true;
|
||||||
|
|
||||||
filetype = lib.mkIf cfg.enableHttpFiletypeAssociation {
|
filetype = lib.mkIf cfg.enableHttpFiletypeAssociation {
|
||||||
extension.http = "http";
|
extension.http = "http";
|
||||||
|
|
|
@ -11,10 +11,6 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
maintainers = [ lib.maintainers.GaetanLepage ];
|
maintainers = [ lib.maintainers.GaetanLepage ];
|
||||||
|
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
curlPackage = lib.mkPackageOption pkgs "curl" {
|
|
||||||
nullable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
gitPackage = lib.mkPackageOption pkgs "git" {
|
gitPackage = lib.mkPackageOption pkgs "git" {
|
||||||
nullable = true;
|
nullable = true;
|
||||||
};
|
};
|
||||||
|
@ -22,9 +18,9 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
|
||||||
extraConfig = cfg: {
|
extraConfig = cfg: {
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
cfg.curlPackage
|
|
||||||
cfg.gitPackage
|
cfg.gitPackage
|
||||||
];
|
];
|
||||||
|
dependencies.curl.enable = lib.mkDefault true;
|
||||||
};
|
};
|
||||||
|
|
||||||
settingsExample = {
|
settingsExample = {
|
||||||
|
|
23
tests/test-sources/modules/dependencies.nix
Normal file
23
tests/test-sources/modules/dependencies.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
override =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
dependencies.git = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.gitMinimal;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
all =
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
options,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
dependencies = lib.mapAttrs (_: depOption: {
|
||||||
|
enable = lib.meta.availableOn pkgs.stdenv.hostPlatform depOption.package.default;
|
||||||
|
}) options.dependencies;
|
||||||
|
};
|
||||||
|
}
|
|
@ -92,10 +92,12 @@
|
||||||
no-packages = {
|
no-packages = {
|
||||||
test.runNvim = false;
|
test.runNvim = false;
|
||||||
|
|
||||||
|
dependencies = {
|
||||||
|
curl.enable = false;
|
||||||
|
};
|
||||||
plugins.image = {
|
plugins.image = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings.backend = "kitty";
|
settings.backend = "kitty";
|
||||||
curlPackage = null;
|
|
||||||
ueberzugPackage = null;
|
ueberzugPackage = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue