diff --git a/nix-conf/home-manager/base/neovim.nix b/nix-conf/home-manager/base/neovim.nix index e69de29..0d3067f 100644 --- a/nix-conf/home-manager/base/neovim.nix +++ b/nix-conf/home-manager/base/neovim.nix @@ -0,0 +1,87 @@ +{ pkgs, lib, config, ... }: +let + # NOTE: Failure 1: buildInputs is pretty much ignored + # my_neovim = pkgs.neovim-unwrapped.overrideDerivation (old: { + # # TODO: is there a more beautiful way to override propagatedBuildInputs? + # name = "hungtr-" + old.name; + # buildInputs = (old.buildInputs or []) ++ [ + # pkgs.tree-sitter # highlighting + # rust_pkgs # for potentially rust-analyzer + # pkgs.fzf + # pkgs.ripgrep + # pkgs.zk + # pkgs.fd + # ]; + # NOTE: Failure 2: propagatedBuildInputs probably only concerns dyn libs + # }); + # NOTE: Failure 3: must be unwrapped neovim because home-manager does the wrapping + # my_neovim = pkgs.neovim; + + # NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace + # and is added to the path after wrapping. + # check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand` + # see: :/--suffix.*PATH + # there should be mentions of additional packages + my_neovim = pkgs.neovim-unwrapped; + rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith + ( + toolchain: + toolchain.default.override { + extensions = [ "rust-src" ]; + } + )); + nvim_pkgs = [ + # pkgs.gccStdenv + pkgs.gcc + pkgs.tree-sitter + pkgs.fzf # file name fuzzy search + pkgs.ripgrep # content fuzzy search + pkgs.zk # Zettelkasten (limited support) + pkgs.fd # Required by a Telescope plugin (?) + pkgs.stdenv.cc.cc.lib + + # Language-specific stuffs + pkgs.sumneko-lua-language-server + pkgs.rust-analyzer + rust_pkgs + pkgs.evcxr # Rust REPL for Conjure! + + # Python3 as alternative to bash scripts :^) + # (pkgs.python310Full.withPackages (pypkgs: [ + # # python-lsp-server's dependencies is absolutely astronomous + # # pypkgs.python-lsp-server # python-lsp. Now we'll have to tell mason to look for this + # pypkgs.pynvim # nvim provider + # pypkgs.ujson # pylsp seems to rely on this. satisfy it lol + # ])) + ]; +in +{ + options.base.neovim = { + enable = lib.mkOption { + default = true; + description = "enable personalized neovim as default editor"; + type = lib.types.bool; + example = false; + }; + }; + config = lib.mkIf config.base.neovim.enable { + programs.neovim = { + enable = true; + package = my_neovim; + viAlias = true; + vimAlias = true; + withPython3 = true; + withNodeJs = true; + extraPackages = nvim_pkgs; + # only for here for archive-documentation + # extraPython3Packages = (pypkgs: [ + # # pypkgs.python-lsp-server + # pypkgs.ujson + # ]); + # I use vim-plug, so I probably don't require packaging + # extraConfig actually writes to init-home-manager.vim (not lua) + # https://github.com/nix-community/home-manager/pull/3287 + # extraConfig = builtins.readFile "${proj_root}/neovim/init.lua"; + }; + }; +} diff --git a/nix-conf/home-manager/home.nix b/nix-conf/home-manager/home.nix index efab2ed..18804b0 100644 --- a/nix-conf/home-manager/home.nix +++ b/nix-conf/home-manager/home.nix @@ -12,62 +12,12 @@ , ... }: let - nvim_pkgs = [ - # Yes, I desperately want neovim to work out-of-the-box without flake.nix for now - # I want at least python LSP to work everywhere because it's basically - # an alternative to bash script when I move to OpenColo - # pkgs.gccStdenv - pkgs.gcc - pkgs.tree-sitter - pkgs.fzf # file name fuzzy search - pkgs.sumneko-lua-language-server - pkgs.ripgrep # content fuzzy search - pkgs.zk # Zettelkasten (limited support) - pkgs.fd # Required by a Telescope plugin (?) - pkgs.stdenv.cc.cc.lib - rust_pkgs - pkgs.rust-analyzer - # Python3 as alternative to bash scripts :^) - # (pkgs.python310Full.withPackages (pypkgs: [ - # # python-lsp-server's dependencies is absolutely astronomous - # # pypkgs.python-lsp-server # python-lsp. Now we'll have to tell mason to look for this - # pypkgs.pynvim # nvim provider - # pypkgs.ujson # pylsp seems to rely on this. satisfy it lol - # ])) - ]; - rust_pkgs = (pkgs.rust-bin.selectLatestNightlyWith - ( - toolchain: - toolchain.default.override { - extensions = [ "rust-src" ]; - } - )); -# NOTE: Failure 1: buildInputs is pretty much ignored -# my_neovim = pkgs.neovim-unwrapped.overrideDerivation (old: { -# # TODO: is there a more beautiful way to override propagatedBuildInputs? -# name = "hungtr-" + old.name; -# buildInputs = (old.buildInputs or []) ++ [ -# pkgs.tree-sitter # highlighting -# rust_pkgs # for potentially rust-analyzer -# pkgs.fzf -# pkgs.ripgrep -# pkgs.zk -# pkgs.fd -# ]; -# NOTE: Failure 2: propagatedBuildInputs probably only concerns dyn libs -# }); - # NOTE: Failure 3: must be unwrapped neovim because home-manager does the wrapping - # my_neovim = pkgs.neovim; - - # NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace - # and is added to the path after wrapping. - # check: nix repl `homeConfigurations.hungtr.config.programs.neovim.finalPackage.buildCommand` - # see: :/--suffix.*PATH - # there should be mentions of additional packages - my_neovim = pkgs.neovim-unwrapped; inherit (myLib) fromYaml; in { + imports = [ + ./base/neovim.nix + ]; home = { username = myHome.username; homeDirectory = myHome.homeDirectory; @@ -98,7 +48,6 @@ in # pkgs.python310Packages.tensorflow # pkgs.python310Packages.scikit-learn ] ++ (myHome.packages or [ ]) - # ++ nvim_pkgs ); ## Configs ## @@ -109,25 +58,6 @@ in programs.jq = { enable = true; }; - # TODO: override the original package, inject tree-sitter and stuffs - programs.neovim = { - enable = true; - package = my_neovim; - viAlias = true; - vimAlias = true; - withPython3 = true; - withNodeJs = true; - extraPackages = nvim_pkgs; - # only for here for archive-documentation - # extraPython3Packages = (pypkgs: [ - # # pypkgs.python-lsp-server - # pypkgs.ujson - # ]); - # I use vim-plug, so I probably don't require packaging - # extraConfig actually writes to init-home-manager.vim (not lua) - # https://github.com/nix-community/home-manager/pull/3287 - # extraConfig = builtins.readFile "${proj_root}/neovim/init.lua"; - }; # not exist in home-manager # have to do it at system level # services.ntp.enable = true; # automatic time diff --git a/templates/rust-monorepo/exec/cli/Cargo.toml b/templates/rust-monorepo/exec/cli/Cargo.toml index c3cd6d1..6d7106a 100644 --- a/templates/rust-monorepo/exec/cli/Cargo.toml +++ b/templates/rust-monorepo/exec/cli/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -core = { version = "0.1.0", path = "../../packages/core" } +corelib = { version = "0.1.0", path = "../../packages/corelib" } diff --git a/templates/rust-monorepo/packages/core/.gitignore b/templates/rust-monorepo/packages/corelib/.gitignore similarity index 100% rename from templates/rust-monorepo/packages/core/.gitignore rename to templates/rust-monorepo/packages/corelib/.gitignore diff --git a/templates/rust-monorepo/packages/core/Cargo.toml b/templates/rust-monorepo/packages/corelib/Cargo.toml similarity index 90% rename from templates/rust-monorepo/packages/core/Cargo.toml rename to templates/rust-monorepo/packages/corelib/Cargo.toml index 900733d..f8d9a89 100644 --- a/templates/rust-monorepo/packages/core/Cargo.toml +++ b/templates/rust-monorepo/packages/corelib/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "core" +name = "corelib" version = "0.1.0" edition = "2021" diff --git a/templates/rust-monorepo/packages/core/src/lib.rs b/templates/rust-monorepo/packages/corelib/src/lib.rs similarity index 100% rename from templates/rust-monorepo/packages/core/src/lib.rs rename to templates/rust-monorepo/packages/corelib/src/lib.rs