From a38d531bf4d02974d9e3088146cbaf896f2fcb00 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 17 Oct 2022 10:21:37 +0100 Subject: [PATCH 1/4] set colorscheme before setting globals (#46) --- modules/output.nix | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/output.nix b/modules/output.nix index 21e45657..2f2fc297 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -75,13 +75,18 @@ in config = let - customRC = config.extraConfigVim + (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPre != "" || config.extraConfigLuaPost != "") '' - lua < Date: Mon, 17 Oct 2022 21:00:18 +0800 Subject: [PATCH 2/4] lualine: fix components config (#47) --- plugins/statuslines/lualine.nix | 59 +++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/plugins/statuslines/lualine.nix b/plugins/statuslines/lualine.nix index 7205b847..31454c01 100644 --- a/plugins/statuslines/lualine.nix +++ b/plugins/statuslines/lualine.nix @@ -20,27 +20,36 @@ let }); default = null; }; - component_options = mode: + component_options = defaultName: mkOption { - type = types.nullOr (types.submodule { - options = { - mode = mkOption { - type = types.str; - default = "${mode}"; + type = types.nullOr (types.listOf (types.oneOf [ + types.str + (types.submodule { + options = { + name = mkOption { + type = types.str; + description = "component name"; + default = defaultName; + }; + icons_enabled = mkOption { + type = types.enum [ "True" "False" ]; + default = "True"; + description = "displays icons in alongside component"; + }; + icon = mkOption { + type = types.nullOr types.str; + default = null; + description = "displays icon in front of the component"; + }; + separator = separators; + extraConfig = mkOption { + type = types.attrs; + default = { }; + description = "extra options for the component"; + }; }; - icons_enabled = mkOption { - type = types.enum [ "True" "False" ]; - default = "True"; - description = "displays icons in alongside component"; - }; - icon = mkOption { - type = types.nullOr types.str; - default = null; - description = "displays icon in front of the component"; - }; - separator = separators; - }; - }); + }) + ])); default = null; }; in @@ -112,6 +121,14 @@ in }; config = let + processComponent = x: (if isAttrs x then processTableComponent else id) x; + processTableComponent = { name, icons_enabled, icon, separator, extraConfig }: mergeAttrs + { + "@" = name; + inherit icons_enabled icon separator; + } + extraConfig; + processSections = sections: mapAttrs (_: mapNullable (map processComponent)) sections; setupOptions = { options = { theme = cfg.theme; @@ -121,8 +138,8 @@ in always_divide_middle = cfg.alwaysDivideMiddle; }; - sections = cfg.sections; - tabline = cfg.tabline; + sections = mapNullable processSections cfg.sections; + tabline = mapNullable processSections cfg.tabline; extensions = cfg.extensions; }; in From f2a103da30c38322d71765949fa387c354b45e88 Mon Sep 17 00:00:00 2001 From: Luc Chabassier Date: Mon, 17 Oct 2022 15:08:17 +0200 Subject: [PATCH 3/4] Allow using global config with hm and nixos (#48) * remove useless nixvim file * reorganize flake outputs * use global config file with home-manager and nixos --- flake.nix | 43 +----- modules/output.nix | 23 ++- nixvim.nix | 306 ---------------------------------------- tests/flake.lock | 59 +++++++- tests/flake.nix | 10 +- wrappers/hm.nix | 23 +++ wrappers/nixos.nix | 24 ++++ wrappers/standalone.nix | 13 ++ 8 files changed, 146 insertions(+), 355 deletions(-) delete mode 100644 nixvim.nix create mode 100644 wrappers/hm.nix create mode 100644 wrappers/nixos.nix create mode 100644 wrappers/standalone.nix diff --git a/flake.nix b/flake.nix index 88d8d030..37d8ed21 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,6 @@ inputs.nmdSrc.url = "gitlab:rycee/nmd"; inputs.nmdSrc.flake = false; - # TODO: Use flake-utils to support all architectures outputs = { self, nixpkgs, nmdSrc, flake-utils, ... }@inputs: with nixpkgs.lib; with builtins; @@ -30,24 +29,11 @@ ./plugins/default.nix ]; - nixvimOption = pkgs: mkOption { - type = types.submodule ((modules pkgs) ++ [{ - options.enable = mkEnableOption "Enable nixvim"; - }]); - }; - - build = pkgs: - configuration: - let - eval = evalModules { - modules = modules pkgs ++ [{ config = configuration; }]; - }; - in - eval.config.output; - flakeOutput = flake-utils.lib.eachDefaultSystem - (system: rec { + (system: let + pkgs = import nixpkgs { inherit system; }; + in { packages.docs = import ./docs { pkgs = import nixpkgs { inherit system; }; lib = nixpkgs.lib; @@ -55,28 +41,11 @@ inherit nmdSrc; }; - nixosModules.nixvim = { pkgs, config, lib, ... }: { - options.programs.nixvim = nixvimOption pkgs; - config = mkIf config.programs.nixvim.enable { - environment.systemPackages = [ - config.programs.nixvim.output - ]; - }; - }; - - homeManagerModules.nixvim = { pkgs, config, lib, ... }: { - options.programs.nixvim = nixvimOption pkgs; - config = mkIf config.programs.nixvim.enable { - home.packages = [ - config.programs.nixvim.output - ]; - }; - }; + legacyPackages.makeNixvim = import ./wrappers/standalone.nix pkgs (modules pkgs); }); in flakeOutput // { - inherit build; - homeManagerModules.nixvim = flakeOutput.homeManagerModules.x86_64-linux.nixvim; - nixosModules.nixvim = flakeOutput.nixosModules.x86_64-linux.nixvim; + nixosModules.nixvim = import ./wrappers/nixos.nix modules; + homeManagerModules.nixvim = import ./wrappers/hm.nix modules; }; } diff --git a/modules/output.nix b/modules/output.nix index 2f2fc297..3db8120f 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -65,9 +65,21 @@ in description = "Extra contents for init.vim"; }; - output = mkOption { + wrapRc = mkOption { + type = types.bool; + description = "Should the config be included in the wrapper script"; + default = false; + }; + + finalPackage = mkOption { type = types.package; - description = "Final package built by nixvim"; + description = "Wrapped neovim"; + readOnly = true; + }; + + initContent = mkOption { + type = types.str; + description = "The content of the init.vim file"; readOnly = true; visible = false; }; @@ -113,9 +125,10 @@ in wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig // { wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs; + inherit (config) wrapRc; }); - in - { - output = wrappedNeovim; + in { + finalPackage = wrappedNeovim; + initContent = neovimConfig.neovimRcContent; }; } diff --git a/nixvim.nix b/nixvim.nix deleted file mode 100644 index 09b06e45..00000000 --- a/nixvim.nix +++ /dev/null @@ -1,306 +0,0 @@ -{ nixos ? false, nixOnDroid ? false, homeManager ? false }: -{ pkgs, lib, config, ... }: -with lib; -let - cfg = config.programs.nixvim; - - pluginWithConfigType = types.submodule { - options = { - config = mkOption { - type = types.lines; - description = "vimscript for this plugin to be placed in init.vim"; - default = ""; - }; - - optional = mkEnableOption "optional" // { - description = "Don't load by default (load with :packadd)"; - }; - - plugin = mkOption { - type = types.package; - description = "vim plugin"; - }; - }; - }; - - mapOption = types.oneOf [ - types.str - (types.submodule { - options = { - silent = mkOption { - type = types.bool; - description = "Whether this mapping should be silent. Equivalent to adding to a map."; - default = false; - }; - - nowait = mkOption { - type = types.bool; - description = "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; - default = false; - }; - - script = mkOption { - type = types.bool; - description = "Equivalent to adding