From 541b69487352e6739a6cd216c0a10ffd895d0d9f Mon Sep 17 00:00:00 2001 From: traxys Date: Mon, 6 Nov 2023 16:26:23 +0100 Subject: [PATCH] docs: Allow to install man pages (#687) --- README.md | 3 +++ flake.nix | 17 +++++++++++------ modules/doc.nix | 7 +++++++ wrappers/darwin.nix | 9 +++++++-- wrappers/hm.nix | 11 +++++++++-- wrappers/nixos.nix | 11 +++++++++-- wrappers/standalone.nix | 11 +++++++++-- 7 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 modules/doc.nix diff --git a/README.md b/README.md index e87891bbc6..ec06086ed8 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,9 @@ be. Documentation is available on this project's GitHub Pages page: [https://nix-community.github.io/nixvim](https://nix-community.github.io/nixvim) +If the option `enableMan` is set to `true` (by default it is), man pages will also +be installed containing the same informations, they can be viewed with `man nixvim`. + ## Plugins After you have installed NixVim, you will no doubt want to enable some plugins. Plugins are based on a modules system, similarly to NixOS and Home Manager. diff --git a/flake.nix b/flake.nix index 3ba668e35c..96d5b91960 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,11 @@ # ./plugins/default.nix ]; + wrapperArgs = { + inherit modules; + inherit self; + }; + flakeOutput = flake-utils.lib.eachDefaultSystem (system: let @@ -66,7 +71,7 @@ # As we test as many things as possible, we need to allow unfree sources by generating # a separate `makeNixvim` module (with pkgs-unfree). makeNixvim = let - makeNixvimWithModuleUnfree = import ./wrappers/standalone.nix pkgs-unfree modules; + makeNixvimWithModuleUnfree = import ./wrappers/standalone.nix pkgs-unfree wrapperArgs; in configuration: makeNixvimWithModuleUnfree { @@ -108,7 +113,7 @@ modules = modules pkgs; }); legacyPackages = rec { - makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules; + makeNixvimWithModule = import ./wrappers/standalone.nix pkgs wrapperArgs; makeNixvim = configuration: makeNixvimWithModule { module = { @@ -126,14 +131,14 @@ in flakeOutput // { - nixosModules.nixvim = import ./wrappers/nixos.nix modules; - homeManagerModules.nixvim = import ./wrappers/hm.nix modules; - nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules; + nixosModules.nixvim = import ./wrappers/nixos.nix wrapperArgs; + homeManagerModules.nixvim = import ./wrappers/hm.nix wrapperArgs; + nixDarwinModules.nixvim = import ./wrappers/darwin.nix wrapperArgs; rawModules.nixvim = nixvimModules; overlays.default = final: prev: { nixvim = rec { - makeNixvimWithModule = import ./wrappers/standalone.nix prev modules; + makeNixvimWithModule = import ./wrappers/standalone.nix prev wrapperArgs; makeNixvim = configuration: makeNixvimWithModule { module = { diff --git a/modules/doc.nix b/modules/doc.nix new file mode 100644 index 0000000000..e93a6676a5 --- /dev/null +++ b/modules/doc.nix @@ -0,0 +1,7 @@ +{lib, ...}: { + options.enableMan = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Install the man pages for nixvim options"; + }; +} diff --git a/wrappers/darwin.nix b/wrappers/darwin.nix index 5a3290c6d9..3b0e249ec5 100644 --- a/wrappers/darwin.nix +++ b/wrappers/darwin.nix @@ -1,4 +1,7 @@ -modules: { +{ + modules, + self, +}: { pkgs, config, lib, @@ -24,7 +27,9 @@ in { config = mkIf cfg.enable (mkMerge [ { - environment.systemPackages = [cfg.finalPackage]; + environment.systemPackages = + [cfg.finalPackage] + ++ (lib.optional cfg.enableMan self.packages.${pkgs.system}.man-docs); } { inherit (cfg) warnings assertions; diff --git a/wrappers/hm.nix b/wrappers/hm.nix index 6fe79201e4..6f0fdecccb 100644 --- a/wrappers/hm.nix +++ b/wrappers/hm.nix @@ -1,4 +1,7 @@ -modules: { +{ + modules, + self, +}: { pkgs, config, lib, @@ -32,7 +35,11 @@ in { config = mkIf cfg.enable (mkMerge [ - {home.packages = [cfg.finalPackage];} + { + home.packages = + [cfg.finalPackage] + ++ (lib.optional cfg.enableMan self.packages.${pkgs.system}.man-docs); + } (mkIf (!cfg.wrapRc) { xdg.configFile = files; }) diff --git a/wrappers/nixos.nix b/wrappers/nixos.nix index c8ee38656f..7f3bca1789 100644 --- a/wrappers/nixos.nix +++ b/wrappers/nixos.nix @@ -1,4 +1,7 @@ -modules: { +{ + modules, + self, +}: { pkgs, config, lib, @@ -33,7 +36,11 @@ in { config = mkIf cfg.enable (mkMerge [ - {environment.systemPackages = [cfg.finalPackage];} + { + environment.systemPackages = + [cfg.finalPackage] + ++ (lib.optional cfg.enableMan self.packages.${pkgs.system}.man-docs); + } (mkIf (!cfg.wrapRc) { environment.etc = files; environment.variables."VIM" = "/etc/nvim"; diff --git a/wrappers/standalone.nix b/wrappers/standalone.nix index 858042cd5d..670921e557 100644 --- a/wrappers/standalone.nix +++ b/wrappers/standalone.nix @@ -1,4 +1,7 @@ -default_pkgs: modules: { +default_pkgs: { + modules, + self, +}: { pkgs ? default_pkgs, extraSpecialArgs ? {}, module, @@ -27,4 +30,8 @@ default_pkgs: modules: { config = handleAssertions eval.config; in - config.finalPackage + config.finalPackage.overrideAttrs (oa: { + paths = + oa.paths + ++ (pkgs.lib.optional config.enableMan self.packages.${pkgs.system}.man-docs); + })