From 72b54ba2553a6fbd8171fa666c46be9785002236 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Wed, 26 Jul 2023 10:39:35 +0900 Subject: [PATCH 01/31] add(nixos): add build dependencies for mason.nvim on NixOS --- nixos/default.nix | 5 ++ nixos/neovim/default.nix | 105 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 nixos/default.nix create mode 100644 nixos/neovim/default.nix diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 000000000..0eefb458b --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./neovim + ]; +} \ No newline at end of file diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix new file mode 100644 index 000000000..d8ea05d8a --- /dev/null +++ b/nixos/neovim/default.nix @@ -0,0 +1,105 @@ +# neovim conf +# I use conf sourcing ./nvim but you can manager from home manager. +{ config +, lib +, pkgs +, ... +}: +with lib; let + cfg = config.programs.neovim.activateNvimDots; + makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; + makeIncludePath = x: makeSearchPathOutput "dev" "include" x; +in +{ + options = { + programs.neovim = { + activateNvimDots = { + enable = mkEnableOption '' + My nvim config + ''; + }; + }; + }; + config = mkIf cfg.enable { + xdg = { + configFile = { + "nvim/lua".source = ../../lua; # windowsとconfigを共有するため.config/nvimで管理する + "nvim/init.lua".source = ../../init.lua; + "nvim/nixos".source = ../../nixos; + }; + }; + home.sessionVariables = { + SQLITE_CLIB_PATH = "${pkgs.sqlite.out}/lib/libsqlite3.so"; + PKG_CONFIG_PATH = makePkgConfigPath (with pkgs; [ openssl hunspell zlib vala libxml2 glib ]); + CPATH = makeIncludePath (with pkgs; [ openssl hunspell ]); + LIBRARY_PATH = makeLibraryPath (with pkgs; [ openssl vala ]); + DOTNET_ROOT = "${pkgs.dotnet-sdk_7}"; + }; + programs.neovim = { + enable = true; # Replace from vi&vim to neovim + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + + withNodeJs = true; + withPython3 = true; + withRuby = true; + + extraPackages = with pkgs; + [ + xclip + + pkg-config + gcc + clang + cmake + gnumake + ninja + + sqlite + deno + openssl + + ripgrep + + neovim-remote + ] + ++ [ + rebar3 # for erlang-ls + hunspell # for gospell + (pkgs.writeShellApplication { + name = "stack"; + text = '' + exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${pkgs.zlib.dev}/include" "--extra-lib-dirs=${pkgs.zlib}/lib" "$@" + ''; + }) + ghc # haskell + # haskellPackages.ghcup + luarocks # lua + phpPackages.composer # php + php #php + cargo # rust + yarn # npm + go # go + openjdk19 # java + julia-bin # julia + dotnet-sdk_7 # dotnet + nim # nim + opam # opam + (rWrapper.override { packages = with pkgs.rPackages; [ xml2 lintr roxygen2 ]; }) # R + meson # vala-language-server + vala # vala-language-server + # haxe # haxe + ]; + + extraPython3Packages = ps: + with ps; [ + isort + docformatter + doq + pynvim + pip + ]; + }; + }; +} From 813ebacad60224683e8393a7d89c2a9766832c90 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Wed, 26 Jul 2023 16:55:16 +0900 Subject: [PATCH 02/31] update(options,setting): merged dont_set_python_host_prog --- lua/core/options.lua | 12 ++++++++---- lua/core/settings.lua | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/core/options.lua b/lua/core/options.lua index 47d7f427d..7545f48e4 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -103,18 +103,22 @@ local function load_options() wrapscan = true, writebackup = false, } + local function isempty(s) return s == nil or s == "" end + local function use_if_defined(val, fallback) + return val ~= nil and val or fallback + end -- custom python provider local conda_prefix = os.getenv("CONDA_PREFIX") if not isempty(conda_prefix) then - vim.g.python_host_prog = conda_prefix .. "/bin/python" - vim.g.python3_host_prog = conda_prefix .. "/bin/python" + vim.g.python_host_prog = use_if_defined(vim.g.python_host_prog, conda_prefix .. "/bin/python") + vim.g.python3_host_prog = use_if_defined(vim.g.python3_host_prog, conda_prefix .. "/bin/python") else - vim.g.python_host_prog = "python" - vim.g.python3_host_prog = "python3" + vim.g.python_host_prog = use_if_defined(vim.g.python_host_prog, "python") + vim.g.python3_host_prog = use_if_defined(vim.g.python3_host_prog, "python3") end for name, value in pairs(global_local) do diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 866de013c..9a88cd7c6 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -40,7 +40,7 @@ settings["load_big_files_faster"] = true -- Settings will complete their replacement at initialization. -- Parameters will be automatically completed as you type. -- Example: { sky = "#04A5E5" } ----@type palette[] +---@type palette settings["palette_overwrite"] = {} -- Set the colorscheme to use here. From 4580c2f0b8f02e51c6489f9aa1764efc21aedfe3 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 01:40:54 +0900 Subject: [PATCH 03/31] add(nixos/neovim): Extend home-manager's programs.neovim. --- nixos/neovim/default.nix | 316 +++++++++++++++++++++++++++++---------- 1 file changed, 236 insertions(+), 80 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index d8ea05d8a..3bffdbe77 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -1,5 +1,4 @@ -# neovim conf -# I use conf sourcing ./nvim but you can manager from home manager. +# home-manager module of neovim setup { config , lib , pkgs @@ -7,99 +6,256 @@ }: with lib; let cfg = config.programs.neovim.activateNvimDots; - makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; - makeIncludePath = x: makeSearchPathOutput "dev" "include" x; in { options = { programs.neovim = { activateNvimDots = { enable = mkEnableOption '' - My nvim config + Activate "ayamir/nvimdots". + Please see details https://github.com/ayamir/nvimdots ''; + withDeno = mkEnableOption '' + Enable Deno provider. Set to `true` to + use Deno plugins. + ''; + withDotnet = mkEnableOption '' + Enable dotnet provider. Set to `true` to + use dotnet plugins. + ''; + withErlang = mkEnableOption '' + Enable Erlang provider. Set to `true` to + use Erlang plugins. + ''; + withGo = mkEnableOption '' + Enable Go provider. Set to `true` to + use Go plugins. + ''; + withHaskell = mkEnableOption '' + Enable Haskell compiler. Set to `true` to + use Haskell plugins. + ''; + withHaxe = mkEnableOption '' + Enable Haxe provider. Set to `true` to + use Haxe plugins. + ''; + withJava = mkEnableOption '' + Enable Java provider. Set to `true` to + use Java plugins. + ''; + withJulia = mkEnableOption '' + Enable Julia provider. Set to `true` to + use Julia plugins. + ''; + withNim = mkEnableOption '' + Enable nim provider. Set to `true` to + use nim plugins. + ''; + withOpam = mkEnableOption '' + Enable Opam provider. Set to `true` to + use Opam plugins. + ''; + withPHP = mkEnableOption '' + Enable PHP provider. Set to `true` to + use PHP plugins. + ''; + withR = mkEnableOption '' + Enable R provider. Set to `true` to + use R plugins. + ''; + withRust = mkEnableOption '' + Enable Rust provider. Set to `true` to + use Rust plugins. + ''; + withVala = mkEnableOption '' + Enable Vala provider. Set to `true` to + use Vala plugins. + ''; + extraRPackages = mkOption { + type = with types; + let fromType = listOf package; + in + coercedTo fromType + (flip warn const '' + Assigning a plain list to extraRPackages is deprecated. + Please assign a function taking a package set as argument, so + extraRPackages = [ pkgs.rPackages.xxx ]; + should become + extraRPackages = rPkgs: with rPkgs; [ xxx ]; + '') + (functionTo fromType); + default = _: [ ]; + defaultText = literalExpression "ps: [ ]"; + example = + literalExpression "rPkgs: with rPkgs; [ xml2 ]"; + description = '' + The extra R packages required for your plugins to work. + This option accepts a function that takes a R package set as an argument, + and selects the required R packages from this package set. + See the example for more info. + ''; + }; + extraHaskellPackages = mkOption { + type = with types; + let fromType = listOf package; + in + coercedTo fromType + (flip warn const '' + Assigning a plain list to extraRPackages is deprecated. + Please assign a function taking a package set as argument, so + extraHaskellPackages = [ pkgs.haskellPackages.xxx ]; + should become + extraHaskellPackages = hsPkgs: with hsPkgs; [ xxx ]; + '') + (functionTo fromType); + default = _: [ ]; + defaultText = literalExpression "ps: [ ]"; + example = + literalExpression "hsPkgs: with hsPkgs; [ haskell-language-server ]"; + description = '' + The extra Haskell packages required for your plugins to work. + This option accepts a function that takes a Haskell package set as an argument, + and selects the required Haskell packages from this package set. + See the example for more info. + ''; + }; + extraPkgConfigPackages = mkOption { + type = with types; listOf package; + default = [ ]; + example = literalExpression "[ pkgs.openssl ]"; + description = "Extra build dependent for pkgconfig."; + }; + extraBuildDependentPackages = mkOption { + type = with types; listOf package; + default = [ ]; + example = literalExpression "[ pkgs.openssl ]"; + description = "Extra build depends to add `LIBRARY_PATH` and `CPATH`."; + }; }; }; }; - config = mkIf cfg.enable { - xdg = { - configFile = { - "nvim/lua".source = ../../lua; # windowsとconfigを共有するため.config/nvimで管理する - "nvim/init.lua".source = ../../init.lua; - "nvim/nixos".source = ../../nixos; - }; - }; - home.sessionVariables = { - SQLITE_CLIB_PATH = "${pkgs.sqlite.out}/lib/libsqlite3.so"; - PKG_CONFIG_PATH = makePkgConfigPath (with pkgs; [ openssl hunspell zlib vala libxml2 glib ]); - CPATH = makeIncludePath (with pkgs; [ openssl hunspell ]); - LIBRARY_PATH = makeLibraryPath (with pkgs; [ openssl vala ]); - DOTNET_ROOT = "${pkgs.dotnet-sdk_7}"; - }; - programs.neovim = { - enable = true; # Replace from vi&vim to neovim - viAlias = true; - vimAlias = true; - vimdiffAlias = true; + config = + let + enabledBash = config.programs.bash.enable; # + enabledFish = config.programs.fish.enable; # shellInit set -x + enabledIon = config.programs.ion.enable; # initExtra export PATH + enabledNushell = config.programs.nushell.enable; # environmentVariables + enabledZsh = config.programs.zsh.enable; - withNodeJs = true; - withPython3 = true; - withRuby = true; + pkg-config-pkgs = with pkgs; [ openssl zlib ] + ++ optional cfg.withGo hunspell + ++ optionals cfg.withR [ libxml2 glib ] + ++ optional cfg.withVala vala + ++ optionals (cfg.extraPkgConfigPackages != [ ]) cfg.extraPkgConfigPackages; - extraPackages = with pkgs; - [ - xclip + include-pkgs = with pkgs; [ openssl zlib ] + ++ optional cfg.withGo hunspell + ++ optionals (cfg.extraBuildDependentPackages != [ ]) cfg.extraBuildDependentPackages; - pkg-config - gcc - clang - cmake - gnumake - ninja + lib-pkgs = with pkgs; [ openssl zlib ] + ++ optional cfg.withVala vala + ++ optionals (cfg.extraBuildDependentPackages != [ ]) cfg.extraBuildDependentPackages; - sqlite - deno - openssl + sessionVariables = + let + makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; + makeIncludePath = x: makeSearchPathOutput "dev" "include" x; + in + { + # "*".sessionVariables"."*_PATH" = mkAfter (cfg.*.sessionVariables."*_PATH" + ":${pkgs.zlib}/lib"), if you add path to `*_PATH`. + SQLITE_CLIB_PATH = "${pkgs.sqlite.out}/lib/libsqlite3.so"; + PKG_CONFIG_PATH = makePkgConfigPath pkg-config-pkgs; + CPATH = makeIncludePath include-pkgs; + LIBRARY_PATH = makeLibraryPath lib-pkgs; + }; # "*".sessionVariables.DOTNET = mkAfter "${pkgs.dotnet-sdk}", if you override `DOTNET_ROOT`. + in + mkIf cfg.enable + { + xdg = { + configFile = { + "nvim/lua".source = ../../lua; + "nvim/init.lua".source = ../../init.lua; + }; + }; + # export build dependent pathes + # Reflecting `home.sessionVariables` requires GUI logout, so set it in each shell + programs.bash.sessionVariables = mkBefore sessionVariables; + programs.fish.shellInit = mkBefore (concatStringsSep "\n" (mapAttrsToList (k: v: "set -x ${k} ${v}") sessionVariables)); + programs.ion.initExtra = mkBefore (concatStringsSep "\n" (mapAttrsToList (k: v: "export ${k}=${v}") sessionVariables)); + programs.nushell.environmentVariables = mkBefore sessionVariables; + programs.zsh.sessionVariables = mkBefore sessionVariables; + home.sessionVariables = optionalAttrs (! enabledBash && enabledFish && enabledIon && enabledNushell && enabledZsh) sessionVariables; - ripgrep + programs.java.enable = cfg.withJava; - neovim-remote - ] - ++ [ - rebar3 # for erlang-ls - hunspell # for gospell - (pkgs.writeShellApplication { - name = "stack"; - text = '' - exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${pkgs.zlib.dev}/include" "--extra-lib-dirs=${pkgs.zlib}/lib" "$@" - ''; - }) - ghc # haskell - # haskellPackages.ghcup - luarocks # lua - phpPackages.composer # php - php #php - cargo # rust - yarn # npm - go # go - openjdk19 # java - julia-bin # julia - dotnet-sdk_7 # dotnet - nim # nim - opam # opam - (rWrapper.override { packages = with pkgs.rPackages; [ xml2 lintr roxygen2 ]; }) # R - meson # vala-language-server - vala # vala-language-server - # haxe # haxe - ]; + programs.neovim = { + enable = true; # Replace from vi&vim to neovim + viAlias = true; + vimAlias = true; + vimdiffAlias = true; - extraPython3Packages = ps: - with ps; [ - isort - docformatter - doq - pynvim - pip - ]; - }; - }; + withNodeJs = true; + withPython3 = true; + withRuby = true; + + extraPackages = with pkgs; + [ + # Build Dependent + pkg-config + clang + gcc + cmake + gnumake + ninja + + # Dependent packages used by default plugins + doq + neovim-remote + ripgrep + sqlite + xclip + + yarn + ] + ++ optional cfg.withDeno deno + ++ optional cfg.withErlang rebar3 + ++ optional cfg.withGo go + ++ optionals cfg.withHaskell [ + ghc + (pkgs.writeShellApplication { + name = "stack"; + text = '' + exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${pkgs.zlib.dev}/include" "--extra-lib-dirs=${pkgs.zlib}/lib" "$@" + ''; + }) + (haskellPackages.ghcWithPackages (ps: [ + # ghcup + ] ++ cfg.extraHaskellPackages pkgs.haskellPackages)) + ] + ++ optional cfg.withHaxe haxe + ++ optional cfg.withJulia julia-bin + ++ optional cfg.withNim nim + ++ optional cfg.withOpam opam + ++ optionals cfg.withPHP [ + php + phpPackages.composer # php + ] + ++ optional cfg.withR (rWrapper.override { + packages = with pkgs.rPackages; + [ xml2 lintr roxygen2 ] + ++ cfg.extraRPackages pkgs.rPackages; + }) + ++ optional cfg.withRust cargo + ++ optionals cfg.withVala [ meson vala ]; + + extraPython3Packages = ps: with ps; [ + isort + docformatter + pynvim + ]; + extraLuaPackages = ls: with ls; [ + luarocks + ]; + }; + }; } From 24c49d60a4b135be86353e95f91d46b29e8107a9 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 01:47:19 +0900 Subject: [PATCH 04/31] add(flake): Providing the home-manager module. --- flake.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..3e2c3ff53 --- /dev/null +++ b/flake.nix @@ -0,0 +1,14 @@ +{ + # This provides only NixOS module + # As of 2023/07/24, you need to depend on nixpkgs-unstable. + # because "doq" is not included in the stable version. + description = "Provide home-manager module for ayamir/neovim"; + + inputs = { }; + + outputs = inputs: { + nixosModules = { + for-hm = ./nixos; + }; + }; +} From 2ec0bbb9011ac921880868d353e7dd145b872577 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 02:41:01 +0900 Subject: [PATCH 05/31] add(nixos/dotnet): Provide dotnet NixOS module --- nixos/default.nix | 3 ++- nixos/dotnet/default.nix | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 nixos/dotnet/default.nix diff --git a/nixos/default.nix b/nixos/default.nix index 0eefb458b..4c88461be 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -1,5 +1,6 @@ { imports = [ + ./dotnet ./neovim ]; -} \ No newline at end of file +} diff --git a/nixos/dotnet/default.nix b/nixos/dotnet/default.nix new file mode 100644 index 000000000..204f230f9 --- /dev/null +++ b/nixos/dotnet/default.nix @@ -0,0 +1,43 @@ +# This module provides DOTNET_ROOT, with a different way to install dotnet locally. +# This module is modified from the NixOS module `programs.dotnet` + +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.programs.dotnet; +in +{ + options = { + programs.dotnet = { + enable = mkEnableOption "" // { + description = '' + Install the DotNet runtime and set the + {env}`DOTNET_ROOT` variable. + ''; + }; + environmentVariables = mkOption { + type = with types; lazyAttrsOf (oneOf [ str path int float ]); + default = { }; + example = { DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = "0"; }; + description = '' + An attribute set an environment variable for DotNET. + ''; + }; + package = mkOption { + type = types.package; + default = pkgs.dotnet-sdk_7; + defaultText = literalExpression "pkgs.dotnet-sdk_7"; + description = "DotNET package to install."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + # Please see https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_root-dotnet_rootx86 + home.sessionVariables = { + DOTNET_ROOT = "${cfg.package}"; + } // cfg.environmentVariables; + }; +} From a13d983942d0ec8dc1de06eff3b432e02351145a Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 02:42:41 +0900 Subject: [PATCH 06/31] feat(nixos/neovim): Correspondence to DotNET. --- nixos/neovim/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 3bffdbe77..4e60a2a98 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -19,9 +19,9 @@ in Enable Deno provider. Set to `true` to use Deno plugins. ''; - withDotnet = mkEnableOption '' + withDotNET = mkEnableOption '' Enable dotnet provider. Set to `true` to - use dotnet plugins. + use DotNET plugins. ''; withErlang = mkEnableOption '' Enable Erlang provider. Set to `true` to @@ -187,6 +187,7 @@ in home.sessionVariables = optionalAttrs (! enabledBash && enabledFish && enabledIon && enabledNushell && enabledZsh) sessionVariables; programs.java.enable = cfg.withJava; + programs.dotnet.enable = cfg.withDotNET; programs.neovim = { enable = true; # Replace from vi&vim to neovim From dbadf18bee771f9026eaa73d78ed396614ed48c2 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 03:34:10 +0900 Subject: [PATCH 07/31] feat(nixos/neovim): enabled `nix-ld`, your need install `nix-ld` without using NixOS. --- nixos/neovim/default.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 4e60a2a98..a70d5461b 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -167,7 +167,7 @@ in PKG_CONFIG_PATH = makePkgConfigPath pkg-config-pkgs; CPATH = makeIncludePath include-pkgs; LIBRARY_PATH = makeLibraryPath lib-pkgs; - }; # "*".sessionVariables.DOTNET = mkAfter "${pkgs.dotnet-sdk}", if you override `DOTNET_ROOT`. + }; in mkIf cfg.enable { @@ -189,6 +189,19 @@ in programs.java.enable = cfg.withJava; programs.dotnet.enable = cfg.withDotNET; + programs.nix-ld = + if attrByPath [ "nix-ld" "enable" ] false config.programs then { + enable = true; + } else if attrByPath [ "nix-ld" "dev" "enable" ] false config.programs then { + dev = { + enable = true; + }; + } else + throw '' + You must install `nix-ld` as NixOSModule. + Please see https://github.com/Mic92/nix-ld/tree/main#installation. + ''; + programs.neovim = { enable = true; # Replace from vi&vim to neovim viAlias = true; From af35feb3eecc6bbd2f9521bd24fa342d63239588 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 03:48:10 +0900 Subject: [PATCH 08/31] Revert "feat(nixos/neovim): enabled `nix-ld`, your need install `nix-ld` without" This reverts commit fe8859790357596b96db3dd4287dbe2d6d4fbf2e. --- nixos/neovim/default.nix | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index a70d5461b..4e60a2a98 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -167,7 +167,7 @@ in PKG_CONFIG_PATH = makePkgConfigPath pkg-config-pkgs; CPATH = makeIncludePath include-pkgs; LIBRARY_PATH = makeLibraryPath lib-pkgs; - }; + }; # "*".sessionVariables.DOTNET = mkAfter "${pkgs.dotnet-sdk}", if you override `DOTNET_ROOT`. in mkIf cfg.enable { @@ -189,19 +189,6 @@ in programs.java.enable = cfg.withJava; programs.dotnet.enable = cfg.withDotNET; - programs.nix-ld = - if attrByPath [ "nix-ld" "enable" ] false config.programs then { - enable = true; - } else if attrByPath [ "nix-ld" "dev" "enable" ] false config.programs then { - dev = { - enable = true; - }; - } else - throw '' - You must install `nix-ld` as NixOSModule. - Please see https://github.com/Mic92/nix-ld/tree/main#installation. - ''; - programs.neovim = { enable = true; # Replace from vi&vim to neovim viAlias = true; From 6baf4245df474b9318687b393339b5afb13ccfd4 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 04:47:38 +0900 Subject: [PATCH 09/31] feat(nixos/neovim): Inspired by "nixos/modules/programs/nix-ld.nix". --- nixos/neovim/default.nix | 89 ++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 4e60a2a98..742a0248a 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -119,12 +119,6 @@ in See the example for more info. ''; }; - extraPkgConfigPackages = mkOption { - type = with types; listOf package; - default = [ ]; - example = literalExpression "[ pkgs.openssl ]"; - description = "Extra build dependent for pkgconfig."; - }; extraBuildDependentPackages = mkOption { type = with types; listOf package; default = [ ]; @@ -136,38 +130,51 @@ in }; config = let - enabledBash = config.programs.bash.enable; # - enabledFish = config.programs.fish.enable; # shellInit set -x - enabledIon = config.programs.ion.enable; # initExtra export PATH - enabledNushell = config.programs.nushell.enable; # environmentVariables - enabledZsh = config.programs.zsh.enable; - - pkg-config-pkgs = with pkgs; [ openssl zlib ] + # From https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/nix-ld.nix + build-dependent-pkgs = with pkgs; + [ + zlib + zstd + stdenv.cc.cc + curl + openssl + attr + libssh + bzip2 + libxml2 + acl + libsodium + util-linux + xz + systemd + glib + clangStdenv.cc + ] + ++ cfg.extraBuildDependentPackages ++ optional cfg.withGo hunspell - ++ optionals cfg.withR [ libxml2 glib ] - ++ optional cfg.withVala vala - ++ optionals (cfg.extraPkgConfigPackages != [ ]) cfg.extraPkgConfigPackages; + ++ optionals cfg.withVala [ vala jsonrpc-glib ]; - include-pkgs = with pkgs; [ openssl zlib ] - ++ optional cfg.withGo hunspell - ++ optionals (cfg.extraBuildDependentPackages != [ ]) cfg.extraBuildDependentPackages; - - lib-pkgs = with pkgs; [ openssl zlib ] - ++ optional cfg.withVala vala - ++ optionals (cfg.extraBuildDependentPackages != [ ]) cfg.extraBuildDependentPackages; + makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; + makeIncludePath = x: makeSearchPathOutput "dev" "include" x; - sessionVariables = - let - makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; - makeIncludePath = x: makeSearchPathOutput "dev" "include" x; - in - { - # "*".sessionVariables"."*_PATH" = mkAfter (cfg.*.sessionVariables."*_PATH" + ":${pkgs.zlib}/lib"), if you add path to `*_PATH`. - SQLITE_CLIB_PATH = "${pkgs.sqlite.out}/lib/libsqlite3.so"; - PKG_CONFIG_PATH = makePkgConfigPath pkg-config-pkgs; - CPATH = makeIncludePath include-pkgs; - LIBRARY_PATH = makeLibraryPath lib-pkgs; - }; # "*".sessionVariables.DOTNET = mkAfter "${pkgs.dotnet-sdk}", if you override `DOTNET_ROOT`. + library-pkgs = pkgs.buildEnv { + name = "library-pkgs"; + pathsToLink = [ "/lib" ]; + paths = map lib.getLib build-dependent-pkgs; + ignoreCollisions = true; + }; + include-pkgs = pkgs.buildEnv { + name = "include-pkgs"; + extraPrefix = "/lib/include"; + paths = splitString ":" (makeIncludePath build-dependent-pkgs); + ignoreCollisions = true; + }; + pkg-config-pkgs = pkgs.buildEnv { + name = "pkg-config-pkgs"; + extraPrefix = "/lib/pkgconfig"; + paths = splitString ":" (makePkgConfigPath build-dependent-pkgs); + ignoreCollisions = true; + }; in mkIf cfg.enable { @@ -177,14 +184,8 @@ in "nvim/init.lua".source = ../../init.lua; }; }; - # export build dependent pathes - # Reflecting `home.sessionVariables` requires GUI logout, so set it in each shell - programs.bash.sessionVariables = mkBefore sessionVariables; - programs.fish.shellInit = mkBefore (concatStringsSep "\n" (mapAttrsToList (k: v: "set -x ${k} ${v}") sessionVariables)); - programs.ion.initExtra = mkBefore (concatStringsSep "\n" (mapAttrsToList (k: v: "export ${k}=${v}") sessionVariables)); - programs.nushell.environmentVariables = mkBefore sessionVariables; - programs.zsh.sessionVariables = mkBefore sessionVariables; - home.sessionVariables = optionalAttrs (! enabledBash && enabledFish && enabledIon && enabledNushell && enabledZsh) sessionVariables; + home.packages = [ library-pkgs include-pkgs pkg-config-pkgs ]; + home.shellAliases.nvim = "SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/pkgconfig CPATH=${config.home.profileDirectory}/lib/include LIBRARY_PATH=${config.home.profileDirectory}/lib LD_LIBRARY_PATH=${config.home.profileDirectory}/lib:''$NIX_LD_LIBRARY_PATH nvim"; programs.java.enable = cfg.withJava; programs.dotnet.enable = cfg.withDotNET; @@ -226,7 +227,7 @@ in (pkgs.writeShellApplication { name = "stack"; text = '' - exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${pkgs.zlib.dev}/include" "--extra-lib-dirs=${pkgs.zlib}/lib" "$@" + exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib" "$@" ''; }) (haskellPackages.ghcWithPackages (ps: [ From 2e2d3c916671c132bd8cfaef202f37134d1918b6 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 06:00:49 +0900 Subject: [PATCH 10/31] fix(nixos/neovim) rename option "extraBuildDependentPackages" to "extraDependentPackages" --- nixos/neovim/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 742a0248a..46a0c5556 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -119,7 +119,7 @@ in See the example for more info. ''; }; - extraBuildDependentPackages = mkOption { + extraDependentPackages = mkOption { type = with types; listOf package; default = [ ]; example = literalExpression "[ pkgs.openssl ]"; @@ -150,7 +150,7 @@ in glib clangStdenv.cc ] - ++ cfg.extraBuildDependentPackages + ++ cfg.extraDependentPackages ++ optional cfg.withGo hunspell ++ optionals cfg.withVala [ vala jsonrpc-glib ]; From b65dc5701b9638fc1e2e188f9f118bd9af6dfbd8 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Thu, 27 Jul 2023 06:59:12 +0900 Subject: [PATCH 11/31] feat(option): Set sqlite_clib_path from environment variable. --- lua/core/options.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/core/options.lua b/lua/core/options.lua index 7545f48e4..943215179 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -125,8 +125,11 @@ local function load_options() vim.o[name] = value end + local sqlite_clib_path = os.getenv("SQLITE_CLIB_PATH") + if not isempty(sqlite_clib_path) then + vim.g.sqlite_clib_path = sqlite_clib_path -- Fix sqlite3 missing-lib issue on Windows - if global.is_windows then + elseif global.is_windows then -- Download the DLLs form https://www.sqlite.org/download.html vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400200/sqlite3.dll" end From e9731feacabf8859e277f99a2762f522b8dde171 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 09:38:00 +0900 Subject: [PATCH 12/31] fix(nixos/neovim): add prefix "nvim-" to extraPrefix of buildEnv and fix alias --- nixos/neovim/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 46a0c5556..fa426dd78 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -130,7 +130,7 @@ in }; config = let - # From https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/nix-ld.nix + # Inspired from https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/nix-ld.nix build-dependent-pkgs = with pkgs; [ zlib @@ -148,7 +148,6 @@ in xz systemd glib - clangStdenv.cc ] ++ cfg.extraDependentPackages ++ optional cfg.withGo hunspell @@ -160,18 +159,19 @@ in library-pkgs = pkgs.buildEnv { name = "library-pkgs"; pathsToLink = [ "/lib" ]; + extraPrefix = "/lib/nvim-lib"; paths = map lib.getLib build-dependent-pkgs; ignoreCollisions = true; }; include-pkgs = pkgs.buildEnv { name = "include-pkgs"; - extraPrefix = "/lib/include"; + extraPrefix = "/lib/nvim-include"; paths = splitString ":" (makeIncludePath build-dependent-pkgs); ignoreCollisions = true; }; pkg-config-pkgs = pkgs.buildEnv { name = "pkg-config-pkgs"; - extraPrefix = "/lib/pkgconfig"; + extraPrefix = "/lib/nvim-pkgconfig"; paths = splitString ":" (makePkgConfigPath build-dependent-pkgs); ignoreCollisions = true; }; @@ -185,7 +185,7 @@ in }; }; home.packages = [ library-pkgs include-pkgs pkg-config-pkgs ]; - home.shellAliases.nvim = "SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/pkgconfig CPATH=${config.home.profileDirectory}/lib/include LIBRARY_PATH=${config.home.profileDirectory}/lib LD_LIBRARY_PATH=${config.home.profileDirectory}/lib:''$NIX_LD_LIBRARY_PATH nvim"; + home.shellAliases.nvim = "SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so CPLUS_INCLUDE_PATH=${pkgs.libcxx.dev}/include/c++/v1 PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/nvim-pkgconfig CPATH=${config.home.profileDirectory}/lib/nvim-include LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-lib LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-lib:''$NIX_LD_LIBRARY_PATH nvim"; programs.java.enable = cfg.withJava; programs.dotnet.enable = cfg.withDotNET; From 361abf017ae92db1ccbb7c52b21d81ed3d793f8e Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 10:09:27 +0900 Subject: [PATCH 13/31] add(nixos/neovim): add `nix-ld` to extraPackages --- nixos/neovim/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index fa426dd78..dc7e678dc 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -202,7 +202,8 @@ in extraPackages = with pkgs; [ - # Build Dependent + nix-ld # + # Build Tools pkg-config clang gcc From e1c1cd8daea0f48baabd35fd45fb95eec54ed2e5 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 10:31:33 +0900 Subject: [PATCH 14/31] Revert "add(nixos/neovim): add `nix-ld` to extraPackages" This reverts commit 361abf017ae92db1ccbb7c52b21d81ed3d793f8e. --- nixos/neovim/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index dc7e678dc..fa426dd78 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -202,8 +202,7 @@ in extraPackages = with pkgs; [ - nix-ld # - # Build Tools + # Build Dependent pkg-config clang gcc From ce311e4f7a37277b188372cfbefc34c5cdf91827 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 11:45:35 +0900 Subject: [PATCH 15/31] feat(nixos/neovim): add 'setBuildEnv' option --- nixos/neovim/default.nix | 55 +++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index fa426dd78..1dfdf5aa4 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -15,6 +15,10 @@ in Activate "ayamir/nvimdots". Please see details https://github.com/ayamir/nvimdots ''; + setBuildEnv = mkEnableOption '' + Sets environment variables that resolve build dependencies needed by `mason.nvim` and `nvim-treesitter` + Environment variables are only visible to `nvim` and have no effect on the session. + ''; withDeno = mkEnableOption '' Enable Deno provider. Set to `true` to use Deno plugins. @@ -147,7 +151,9 @@ in util-linux xz systemd + # Packages not included in `nix-ld`'s NixOSModule glib + libcxx ] ++ cfg.extraDependentPackages ++ optional cfg.withGo hunspell @@ -156,43 +162,50 @@ in makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; makeIncludePath = x: makeSearchPathOutput "dev" "include" x; - library-pkgs = pkgs.buildEnv { - name = "library-pkgs"; - pathsToLink = [ "/lib" ]; - extraPrefix = "/lib/nvim-lib"; + nvim-depends-library = pkgs.buildEnv { + name = "nvim-depends-library"; paths = map lib.getLib build-dependent-pkgs; + extraPrefix = "/lib/nvim-depends"; + pathsToLink = [ "/lib" ]; ignoreCollisions = true; }; - include-pkgs = pkgs.buildEnv { - name = "include-pkgs"; - extraPrefix = "/lib/nvim-include"; + nvim-depends-include = pkgs.buildEnv { + name = "nvim-depends-include"; paths = splitString ":" (makeIncludePath build-dependent-pkgs); + extraPrefix = "/lib/nvim-depends/include"; ignoreCollisions = true; }; - pkg-config-pkgs = pkgs.buildEnv { - name = "pkg-config-pkgs"; - extraPrefix = "/lib/nvim-pkgconfig"; + nvim-depends-pkgconfig = pkgs.buildEnv { + name = "nvim-depends-pkgconfig"; paths = splitString ":" (makePkgConfigPath build-dependent-pkgs); + extraPrefix = "/lib/nvim-depends/pkgconfig"; ignoreCollisions = true; }; + buildEnv = [ + "SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so" + "CPLUS_INCLUDE_PATH=${config.home.profileDirectory}/lib/nvim-depends/include/c++/v1" + "PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/nvim-depends/pkgconfig" + "CPATH=${config.home.profileDirectory}/lib/nvim-depends/include" + "LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" + "LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib:$NIX_LD_LIBRARY_PATH" + ]; in mkIf cfg.enable { - xdg = { - configFile = { - "nvim/lua".source = ../../lua; - "nvim/init.lua".source = ../../init.lua; - }; + xdg.configFile = { + "nvim/lua".source = ../../lua; + "nvim/init.lua".source = ../../init.lua; }; - home.packages = [ library-pkgs include-pkgs pkg-config-pkgs ]; - home.shellAliases.nvim = "SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so CPLUS_INCLUDE_PATH=${pkgs.libcxx.dev}/include/c++/v1 PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/nvim-pkgconfig CPATH=${config.home.profileDirectory}/lib/nvim-include LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-lib LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-lib:''$NIX_LD_LIBRARY_PATH nvim"; + home.packages = optionals cfg.setBuildEnv [ nvim-depends-library nvim-depends-include nvim-depends-pkgconfig ]; + home.extraOutputsToInstall = optional cfg.setBuildEnv "nvim-depends"; + home.shellAliases.nvim = optionalString cfg.setBuildEnv (concatStringsSep " " buildEnv) + " " + "nvim"; programs.java.enable = cfg.withJava; programs.dotnet.enable = cfg.withDotNET; programs.neovim = { - enable = true; # Replace from vi&vim to neovim - viAlias = true; + enable = true; + viAlias = true; # Replace from vi&vim to neovim vimAlias = true; vimdiffAlias = true; @@ -202,7 +215,7 @@ in extraPackages = with pkgs; [ - # Build Dependent + # Build Tools pkg-config clang gcc @@ -231,7 +244,7 @@ in ''; }) (haskellPackages.ghcWithPackages (ps: [ - # ghcup + # ghcup # ghcup is broken ] ++ cfg.extraHaskellPackages pkgs.haskellPackages)) ] ++ optional cfg.withHaxe haxe From d809af510e438919b57d9ebd927d74e725af38fa Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 11:46:35 +0900 Subject: [PATCH 16/31] style(nixos): Change key of dotnet module --- nixos/dotnet/default.nix | 4 ++-- nixos/neovim/default.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/dotnet/default.nix b/nixos/dotnet/default.nix index 204f230f9..af671e1d3 100644 --- a/nixos/dotnet/default.nix +++ b/nixos/dotnet/default.nix @@ -4,11 +4,11 @@ { config, lib, pkgs, ... }: with lib; let - cfg = config.programs.dotnet; + cfg = config.programs.dotnet.dev; in { options = { - programs.dotnet = { + programs.dotnet.dev = { enable = mkEnableOption "" // { description = '' Install the DotNet runtime and set the diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 1dfdf5aa4..0ced37676 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -201,7 +201,7 @@ in home.shellAliases.nvim = optionalString cfg.setBuildEnv (concatStringsSep " " buildEnv) + " " + "nvim"; programs.java.enable = cfg.withJava; - programs.dotnet.enable = cfg.withDotNET; + programs.dotnet.dev.enable = cfg.withDotNET; programs.neovim = { enable = true; From 49caa70198eedeea2e3f730f240369a1383494ee Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 14:29:35 +0900 Subject: [PATCH 17/31] feat(nixos/neovim): Set NIX_LD_LIBRARY_PATH myself. Including packages included in `nix-ld`'s NixOSModule --- nixos/neovim/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 0ced37676..e9b4e172c 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -187,7 +187,8 @@ in "PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/nvim-depends/pkgconfig" "CPATH=${config.home.profileDirectory}/lib/nvim-depends/include" "LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" - "LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib:$NIX_LD_LIBRARY_PATH" + "LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" + "NIX_LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" ]; in mkIf cfg.enable From 98bbe98d2d7aaac90177b57d0a1564353b0672e3 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 15:04:48 +0900 Subject: [PATCH 18/31] feat(flake.nix): Change module name. --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 3e2c3ff53..2130cb672 100644 --- a/flake.nix +++ b/flake.nix @@ -2,13 +2,13 @@ # This provides only NixOS module # As of 2023/07/24, you need to depend on nixpkgs-unstable. # because "doq" is not included in the stable version. - description = "Provide home-manager module for ayamir/neovim"; + description = "Provide nixosModules for ayamir/nvimdots"; inputs = { }; outputs = inputs: { nixosModules = { - for-hm = ./nixos; + nvimdots = ./nixos; }; }; } From d58cafffe746a7d05972f3c3703a4905beaa313f Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 15:24:26 +0900 Subject: [PATCH 19/31] fix(nixos/neovim): Remove deno and option to install build tools such as gcc --- nixos/neovim/default.nix | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index e9b4e172c..0ca17cc0b 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -18,10 +18,11 @@ in setBuildEnv = mkEnableOption '' Sets environment variables that resolve build dependencies needed by `mason.nvim` and `nvim-treesitter` Environment variables are only visible to `nvim` and have no effect on the session. + Required for NixOS. ''; - withDeno = mkEnableOption '' - Enable Deno provider. Set to `true` to - use Deno plugins. + withBuildTools = mkEnableOption '' + Include basic build tools like `gcc` and `pkg-config`. + Required for NixOS. ''; withDotNET = mkEnableOption '' Enable dotnet provider. Set to `true` to @@ -216,14 +217,6 @@ in extraPackages = with pkgs; [ - # Build Tools - pkg-config - clang - gcc - cmake - gnumake - ninja - # Dependent packages used by default plugins doq neovim-remote @@ -233,7 +226,14 @@ in yarn ] - ++ optional cfg.withDeno deno + ++ optionals cfg.withBuildTools [ + pkg-config + clang + gcc + cmake + gnumake + ninja + ] ++ optional cfg.withErlang rebar3 ++ optional cfg.withGo go ++ optionals cfg.withHaskell [ From 08d43ccc95e83db209b17082270adbb988409953 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Fri, 28 Jul 2023 21:48:27 +0900 Subject: [PATCH 20/31] fix(nixos/neovim): Removed clipboard and neovim-remote, changed ripgrep install location, set sqlite environment variable to default --- nixos/neovim/default.nix | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 0ca17cc0b..80e62598e 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -183,13 +183,12 @@ in ignoreCollisions = true; }; buildEnv = [ - "SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so" - "CPLUS_INCLUDE_PATH=${config.home.profileDirectory}/lib/nvim-depends/include/c++/v1" - "PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/nvim-depends/pkgconfig" "CPATH=${config.home.profileDirectory}/lib/nvim-depends/include" - "LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" + "CPLUS_INCLUDE_PATH=${config.home.profileDirectory}/lib/nvim-depends/include/c++/v1" "LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" + "LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" "NIX_LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" + "PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/nvim-depends/pkgconfig" ]; in mkIf cfg.enable @@ -198,9 +197,11 @@ in "nvim/lua".source = ../../lua; "nvim/init.lua".source = ../../init.lua; }; - home.packages = optionals cfg.setBuildEnv [ nvim-depends-library nvim-depends-include nvim-depends-pkgconfig ]; + home.packages = with pkgs; [ + ripgrep + ] ++ optionals cfg.setBuildEnv [ patchelf nvim-depends-library nvim-depends-include nvim-depends-pkgconfig ]; home.extraOutputsToInstall = optional cfg.setBuildEnv "nvim-depends"; - home.shellAliases.nvim = optionalString cfg.setBuildEnv (concatStringsSep " " buildEnv) + " " + "nvim"; + home.shellAliases.nvim = optionalString cfg.setBuildEnv (concatStringsSep " " buildEnv) + " SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so " + "nvim"; programs.java.enable = cfg.withJava; programs.dotnet.dev.enable = cfg.withDotNET; @@ -219,10 +220,7 @@ in [ # Dependent packages used by default plugins doq - neovim-remote - ripgrep sqlite - xclip yarn ] From 36d0b3d920f6e4e5397646ddb522f8c8aa43af93 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Sat, 29 Jul 2023 15:29:55 +0900 Subject: [PATCH 21/31] fix(nixos/neovim): Change submodule name. --- nixos/neovim/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 80e62598e..33ed8dd9c 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -5,12 +5,12 @@ , ... }: with lib; let - cfg = config.programs.neovim.activateNvimDots; + cfg = config.programs.neovim.nvimdots; in { options = { programs.neovim = { - activateNvimDots = { + nvimdots = { enable = mkEnableOption '' Activate "ayamir/nvimdots". Please see details https://github.com/ayamir/nvimdots From c390f5df32a82438ad3a282665914575d3e448a6 Mon Sep 17 00:00:00 2001 From: MiSumiSumi Date: Wed, 9 Aug 2023 18:41:03 +0900 Subject: [PATCH 22/31] Update nixos/default.nix Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com> Signed-off-by: MiSumiSumi --- nixos/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/default.nix b/nixos/default.nix index 4c88461be..c0e5e052d 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -1,3 +1,4 @@ +# NOTE: to add more language support, make a directory under `nixos`, followed by the language name and `default.nix`. See `dotnet/default.nix` for example. { imports = [ ./dotnet From be7a1bf5a8836b722c64694ca2e8e7cdd2633949 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Wed, 9 Aug 2023 23:41:38 +0900 Subject: [PATCH 23/31] feat(neovim/default.nix): Clean up language support --- nixos/neovim/default.nix | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 33ed8dd9c..0800ca048 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -28,10 +28,6 @@ in Enable dotnet provider. Set to `true` to use DotNET plugins. ''; - withErlang = mkEnableOption '' - Enable Erlang provider. Set to `true` to - use Erlang plugins. - ''; withGo = mkEnableOption '' Enable Go provider. Set to `true` to use Go plugins. @@ -40,26 +36,10 @@ in Enable Haskell compiler. Set to `true` to use Haskell plugins. ''; - withHaxe = mkEnableOption '' - Enable Haxe provider. Set to `true` to - use Haxe plugins. - ''; withJava = mkEnableOption '' Enable Java provider. Set to `true` to use Java plugins. ''; - withJulia = mkEnableOption '' - Enable Julia provider. Set to `true` to - use Julia plugins. - ''; - withNim = mkEnableOption '' - Enable nim provider. Set to `true` to - use nim plugins. - ''; - withOpam = mkEnableOption '' - Enable Opam provider. Set to `true` to - use Opam plugins. - ''; withPHP = mkEnableOption '' Enable PHP provider. Set to `true` to use PHP plugins. @@ -68,10 +48,6 @@ in Enable R provider. Set to `true` to use R plugins. ''; - withRust = mkEnableOption '' - Enable Rust provider. Set to `true` to - use Rust plugins. - ''; withVala = mkEnableOption '' Enable Vala provider. Set to `true` to use Vala plugins. @@ -221,8 +197,6 @@ in # Dependent packages used by default plugins doq sqlite - - yarn ] ++ optionals cfg.withBuildTools [ pkg-config @@ -231,8 +205,9 @@ in cmake gnumake ninja + cargo + yarn ] - ++ optional cfg.withErlang rebar3 ++ optional cfg.withGo go ++ optionals cfg.withHaskell [ ghc @@ -246,10 +221,6 @@ in # ghcup # ghcup is broken ] ++ cfg.extraHaskellPackages pkgs.haskellPackages)) ] - ++ optional cfg.withHaxe haxe - ++ optional cfg.withJulia julia-bin - ++ optional cfg.withNim nim - ++ optional cfg.withOpam opam ++ optionals cfg.withPHP [ php phpPackages.composer # php @@ -259,7 +230,6 @@ in [ xml2 lintr roxygen2 ] ++ cfg.extraRPackages pkgs.rPackages; }) - ++ optional cfg.withRust cargo ++ optionals cfg.withVala [ meson vala ]; extraPython3Packages = ps: with ps; [ From b310ddd1292cba2bf7e2ce8925ff3c294e9469e8 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Sun, 13 Aug 2023 02:41:54 +0900 Subject: [PATCH 24/31] feat(nixos): Include `snips` and `tutor` under `$XDG_CONFIG_HOME/nvim` --- nixos/neovim/default.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 0800ca048..70e3acd1f 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -1,4 +1,4 @@ -# home-manager module of neovim setup +# home-manager module of neovim setup { config , lib , pkgs @@ -25,11 +25,11 @@ in Required for NixOS. ''; withDotNET = mkEnableOption '' - Enable dotnet provider. Set to `true` to + Enable dotnet provider. Set to `true` to use DotNET plugins. ''; withGo = mkEnableOption '' - Enable Go provider. Set to `true` to + Enable Go provider. Set to `true` to use Go plugins. ''; withHaskell = mkEnableOption '' @@ -41,15 +41,15 @@ in use Java plugins. ''; withPHP = mkEnableOption '' - Enable PHP provider. Set to `true` to + Enable PHP provider. Set to `true` to use PHP plugins. ''; withR = mkEnableOption '' - Enable R provider. Set to `true` to + Enable R provider. Set to `true` to use R plugins. ''; withVala = mkEnableOption '' - Enable Vala provider. Set to `true` to + Enable Vala provider. Set to `true` to use Vala plugins. ''; extraRPackages = mkOption { @@ -170,8 +170,10 @@ in mkIf cfg.enable { xdg.configFile = { - "nvim/lua".source = ../../lua; "nvim/init.lua".source = ../../init.lua; + "nvim/lua".source = ../../lua; + "nvim/snips".source = ../../snips; + "nvim/tutor".source = ../../tutor; }; home.packages = with pkgs; [ ripgrep From 645846f9d8670240cd1a297c20619d26dcc691d6 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Sun, 13 Aug 2023 11:49:44 +0900 Subject: [PATCH 25/31] fix(nixos): Fix `stack` `extra-include-dirs` and `extra-lib-dirs` --- nixos/neovim/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 70e3acd1f..ed4d4246c 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -216,7 +216,7 @@ in (pkgs.writeShellApplication { name = "stack"; text = '' - exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib" "$@" + exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/nvim-depends/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib/nvim-depends/lib" "$@" ''; }) (haskellPackages.ghcWithPackages (ps: [ From ddc2dce90519bf1c6272bd93b657ceff1526d33e Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Sun, 13 Aug 2023 15:53:49 +0900 Subject: [PATCH 26/31] remove(nixos): Remove some language support --- nixos/neovim/default.nix | 69 ++-------------------------------------- 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index ed4d4246c..a3108d617 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -24,58 +24,10 @@ in Include basic build tools like `gcc` and `pkg-config`. Required for NixOS. ''; - withDotNET = mkEnableOption '' - Enable dotnet provider. Set to `true` to - use DotNET plugins. - ''; - withGo = mkEnableOption '' - Enable Go provider. Set to `true` to - use Go plugins. - ''; withHaskell = mkEnableOption '' Enable Haskell compiler. Set to `true` to use Haskell plugins. ''; - withJava = mkEnableOption '' - Enable Java provider. Set to `true` to - use Java plugins. - ''; - withPHP = mkEnableOption '' - Enable PHP provider. Set to `true` to - use PHP plugins. - ''; - withR = mkEnableOption '' - Enable R provider. Set to `true` to - use R plugins. - ''; - withVala = mkEnableOption '' - Enable Vala provider. Set to `true` to - use Vala plugins. - ''; - extraRPackages = mkOption { - type = with types; - let fromType = listOf package; - in - coercedTo fromType - (flip warn const '' - Assigning a plain list to extraRPackages is deprecated. - Please assign a function taking a package set as argument, so - extraRPackages = [ pkgs.rPackages.xxx ]; - should become - extraRPackages = rPkgs: with rPkgs; [ xxx ]; - '') - (functionTo fromType); - default = _: [ ]; - defaultText = literalExpression "ps: [ ]"; - example = - literalExpression "rPkgs: with rPkgs; [ xml2 ]"; - description = '' - The extra R packages required for your plugins to work. - This option accepts a function that takes a R package set as an argument, - and selects the required R packages from this package set. - See the example for more info. - ''; - }; extraHaskellPackages = mkOption { type = with types; let fromType = listOf package; @@ -132,9 +84,7 @@ in glib libcxx ] - ++ cfg.extraDependentPackages - ++ optional cfg.withGo hunspell - ++ optionals cfg.withVala [ vala jsonrpc-glib ]; + ++ cfg.extraDependentPackages; makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; makeIncludePath = x: makeSearchPathOutput "dev" "include" x; @@ -181,9 +131,6 @@ in home.extraOutputsToInstall = optional cfg.setBuildEnv "nvim-depends"; home.shellAliases.nvim = optionalString cfg.setBuildEnv (concatStringsSep " " buildEnv) + " SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so " + "nvim"; - programs.java.enable = cfg.withJava; - programs.dotnet.dev.enable = cfg.withDotNET; - programs.neovim = { enable = true; viAlias = true; # Replace from vi&vim to neovim @@ -210,9 +157,7 @@ in cargo yarn ] - ++ optional cfg.withGo go ++ optionals cfg.withHaskell [ - ghc (pkgs.writeShellApplication { name = "stack"; text = '' @@ -222,17 +167,7 @@ in (haskellPackages.ghcWithPackages (ps: [ # ghcup # ghcup is broken ] ++ cfg.extraHaskellPackages pkgs.haskellPackages)) - ] - ++ optionals cfg.withPHP [ - php - phpPackages.composer # php - ] - ++ optional cfg.withR (rWrapper.override { - packages = with pkgs.rPackages; - [ xml2 lintr roxygen2 ] - ++ cfg.extraRPackages pkgs.rPackages; - }) - ++ optionals cfg.withVala [ meson vala ]; + ]; extraPython3Packages = ps: with ps; [ isort From 3e6da569a120b232f64404351c41c327fb78da95 Mon Sep 17 00:00:00 2001 From: Sumi-Sumi Date: Sat, 19 Aug 2023 12:46:48 +0900 Subject: [PATCH 27/31] fix(nixos): Remove alias settings --- nixos/neovim/default.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index a3108d617..48c356410 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -133,9 +133,6 @@ in programs.neovim = { enable = true; - viAlias = true; # Replace from vi&vim to neovim - vimAlias = true; - vimdiffAlias = true; withNodeJs = true; withPython3 = true; From d145ef0c79bad5a0b9050c936aea7574120d67e1 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 19 Aug 2023 13:42:32 +0800 Subject: [PATCH 28/31] fixups after merging 'main' --- lua/core/options.lua | 1 + lua/core/settings.lua | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/core/options.lua b/lua/core/options.lua index 943215179..529c77f0e 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -126,6 +126,7 @@ local function load_options() end local sqlite_clib_path = os.getenv("SQLITE_CLIB_PATH") + -- Try environment variable first if not isempty(sqlite_clib_path) then vim.g.sqlite_clib_path = sqlite_clib_path -- Fix sqlite3 missing-lib issue on Windows diff --git a/lua/core/settings.lua b/lua/core/settings.lua index ea5bfced1..c4d8d4517 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -44,7 +44,7 @@ settings["load_big_files_faster"] = true -- Settings will complete their replacement at initialization. -- Parameters will be automatically completed as you type. -- Example: { sky = "#04A5E5" } ----@type palette +---@type palette[] settings["palette_overwrite"] = {} -- Set the colorscheme to use here. From 5ce0a8cab49a3b9640c2954bd4001c742527d119 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 19 Aug 2023 14:02:06 +0800 Subject: [PATCH 29/31] (nix) update docs --- flake.nix | 2 +- nixos/neovim/default.nix | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index 2130cb672..77e2746db 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { # This provides only NixOS module - # As of 2023/07/24, you need to depend on nixpkgs-unstable. + # As of 2023/08/19, you need to depend on nixpkgs-unstable. # because "doq" is not included in the stable version. description = "Provide nixosModules for ayamir/nvimdots"; diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 48c356410..e80d84c8d 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -13,11 +13,11 @@ in nvimdots = { enable = mkEnableOption '' Activate "ayamir/nvimdots". - Please see details https://github.com/ayamir/nvimdots + Have a look at https://github.com/ayamir/nvimdots for details ''; setBuildEnv = mkEnableOption '' - Sets environment variables that resolve build dependencies needed by `mason.nvim` and `nvim-treesitter` - Environment variables are only visible to `nvim` and have no effect on the session. + Sets environment variables that resolve build dependencies as required by `mason.nvim` and `nvim-treesitter` + Environment variables are only visible to `nvim` and have no effect on any parent sessions. Required for NixOS. ''; withBuildTools = mkEnableOption '' @@ -25,7 +25,7 @@ in Required for NixOS. ''; withHaskell = mkEnableOption '' - Enable Haskell compiler. Set to `true` to + Enable the Haskell compiler. Set to `true` to use Haskell plugins. ''; extraHaskellPackages = mkOption { @@ -37,7 +37,7 @@ in Assigning a plain list to extraRPackages is deprecated. Please assign a function taking a package set as argument, so extraHaskellPackages = [ pkgs.haskellPackages.xxx ]; - should become + should be extraHaskellPackages = hsPkgs: with hsPkgs; [ xxx ]; '') (functionTo fromType); From 1728366c87fef225f50c7dc0fd7862f9aab7962c Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:11:57 +0800 Subject: [PATCH 30/31] (readme) update docs --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4caf7d73e..b5b5730c2 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ ## 🪷 Introduction -This repo hosts my [NeoVim](https://neovim.io/) configuration for Linux, macOS, and Windows. `init.lua` is the config entry point. +This repo hosts my [NeoVim](https://neovim.io/) configuration for Linux [(with NixOS support)](#nixos-support), macOS, and Windows. `init.lua` is the config entry point. Branch info: @@ -50,7 +50,7 @@ Branch info: -I use [lazy.nvim](https://github.com/folke/lazy.nvim) to manage plugins. +Plugins are managed using [lazy.nvim](https://github.com/folke/lazy.nvim). Chinese introduction is [here](https://zhuanlan.zhihu.com/p/382092667). @@ -89,25 +89,31 @@ It's strongly recommended to read [Wiki: Prerequisites](https://github.com/ayami

🗺️ Keybindings

-

Refer to Wiki: Keybindings

+

See Wiki: Keybindings for details


🔌 Plugins & Deps

-

Refer to Wiki: Plugins
(You can also find a deps diagram there!)

+

See Wiki: Plugins for details
(You can also find a deps diagram there!)


🔧 Usage & Customization

-

Refer to Wiki: Usage

+

See Wiki: Usage for details

+
+ +

+ ❄️ NixOS Support +

+

See Wiki: NixOS Support for details


🤔 FAQ

-

Refer to Wiki: FAQ

+

See Wiki: FAQ for details

## ✨ Features From 92b3150d1df00a2a28d2c02666fcd2ac60f77228 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:15:21 +0800 Subject: [PATCH 31/31] fixup! (readme) update docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b5b5730c2..59286771d 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ ## 🪷 Introduction -This repo hosts my [NeoVim](https://neovim.io/) configuration for Linux [(with NixOS support)](#nixos-support), macOS, and Windows. `init.lua` is the config entry point. +This repo hosts our [NeoVim](https://neovim.io/) configuration for Linux [(with NixOS support)](#nixos-support), macOS, and Windows. `init.lua` is the config entry point. Branch info: @@ -50,7 +50,7 @@ Branch info: -Plugins are managed using [lazy.nvim](https://github.com/folke/lazy.nvim). +We currently manage plugins using [lazy.nvim](https://github.com/folke/lazy.nvim). Chinese introduction is [here](https://zhuanlan.zhihu.com/p/382092667).