-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: implement NixOS support (#906)
* add(nixos): add build dependencies for mason.nvim on NixOS * update(options,setting): merged dont_set_python_host_prog * add(nixos/neovim): Extend home-manager's programs.neovim. * add(flake): Providing the home-manager module. * add(nixos/dotnet): Provide dotnet NixOS module * feat(nixos/neovim): Correspondence to DotNET. * feat(nixos/neovim): enabled `nix-ld`, your need install `nix-ld` without using NixOS. * Revert "feat(nixos/neovim): enabled `nix-ld`, your need install `nix-ld` without" This reverts commit fe88597. * feat(nixos/neovim): Inspired by "nixos/modules/programs/nix-ld.nix". * fix(nixos/neovim) rename option "extraBuildDependentPackages" to "extraDependentPackages" * feat(option): Set sqlite_clib_path from environment variable. * fix(nixos/neovim): add prefix "nvim-" to extraPrefix of buildEnv and fix alias * add(nixos/neovim): add `nix-ld` to extraPackages * Revert "add(nixos/neovim): add `nix-ld` to extraPackages" This reverts commit 361abf0. * feat(nixos/neovim): add 'setBuildEnv' option * style(nixos): Change key of dotnet module * feat(nixos/neovim): Set NIX_LD_LIBRARY_PATH myself. Including packages included in `nix-ld`'s NixOSModule * feat(flake.nix): Change module name. * fix(nixos/neovim): Remove deno and option to install build tools such as gcc * fix(nixos/neovim): Removed clipboard and neovim-remote, changed ripgrep install location, set sqlite environment variable to default * fix(nixos/neovim): Change submodule name. * Update nixos/default.nix Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com> Signed-off-by: MiSumiSumi <dragon511southern@gmail.com> * feat(neovim/default.nix): Clean up language support * feat(nixos): Include `snips` and `tutor` under `$XDG_CONFIG_HOME/nvim` * fix(nixos): Fix `stack` `extra-include-dirs` and `extra-lib-dirs` * remove(nixos): Remove some language support * fix(nixos): Remove alias settings * fixups after merging 'main' * (nix) update docs * (readme) update docs * fixup! (readme) update docs --------- Signed-off-by: MiSumiSumi <dragon511southern@gmail.com> Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
- Loading branch information
1 parent
10e2e49
commit 3a51040
Showing
6 changed files
with
260 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
# This provides only NixOS module | ||
# 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"; | ||
|
||
inputs = { }; | ||
|
||
outputs = inputs: { | ||
nixosModules = { | ||
nvimdots = ./nixos; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 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 | ||
./neovim | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.dev; | ||
in | ||
{ | ||
options = { | ||
programs.dotnet.dev = { | ||
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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
# home-manager module of neovim setup | ||
{ config | ||
, lib | ||
, pkgs | ||
, ... | ||
}: | ||
with lib; let | ||
cfg = config.programs.neovim.nvimdots; | ||
in | ||
{ | ||
options = { | ||
programs.neovim = { | ||
nvimdots = { | ||
enable = mkEnableOption '' | ||
Activate "ayamir/nvimdots". | ||
Have a look at https://github.com/ayamir/nvimdots for details | ||
''; | ||
setBuildEnv = mkEnableOption '' | ||
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 '' | ||
Include basic build tools like `gcc` and `pkg-config`. | ||
Required for NixOS. | ||
''; | ||
withHaskell = mkEnableOption '' | ||
Enable the Haskell compiler. Set to `true` to | ||
use Haskell plugins. | ||
''; | ||
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 be | ||
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. | ||
''; | ||
}; | ||
extraDependentPackages = mkOption { | ||
type = with types; listOf package; | ||
default = [ ]; | ||
example = literalExpression "[ pkgs.openssl ]"; | ||
description = "Extra build depends to add `LIBRARY_PATH` and `CPATH`."; | ||
}; | ||
}; | ||
}; | ||
}; | ||
config = | ||
let | ||
# Inspired 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 | ||
# Packages not included in `nix-ld`'s NixOSModule | ||
glib | ||
libcxx | ||
] | ||
++ cfg.extraDependentPackages; | ||
|
||
makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; | ||
makeIncludePath = x: makeSearchPathOutput "dev" "include" x; | ||
|
||
nvim-depends-library = pkgs.buildEnv { | ||
name = "nvim-depends-library"; | ||
paths = map lib.getLib build-dependent-pkgs; | ||
extraPrefix = "/lib/nvim-depends"; | ||
pathsToLink = [ "/lib" ]; | ||
ignoreCollisions = true; | ||
}; | ||
nvim-depends-include = pkgs.buildEnv { | ||
name = "nvim-depends-include"; | ||
paths = splitString ":" (makeIncludePath build-dependent-pkgs); | ||
extraPrefix = "/lib/nvim-depends/include"; | ||
ignoreCollisions = true; | ||
}; | ||
nvim-depends-pkgconfig = pkgs.buildEnv { | ||
name = "nvim-depends-pkgconfig"; | ||
paths = splitString ":" (makePkgConfigPath build-dependent-pkgs); | ||
extraPrefix = "/lib/nvim-depends/pkgconfig"; | ||
ignoreCollisions = true; | ||
}; | ||
buildEnv = [ | ||
"CPATH=${config.home.profileDirectory}/lib/nvim-depends/include" | ||
"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 | ||
{ | ||
xdg.configFile = { | ||
"nvim/init.lua".source = ../../init.lua; | ||
"nvim/lua".source = ../../lua; | ||
"nvim/snips".source = ../../snips; | ||
"nvim/tutor".source = ../../tutor; | ||
}; | ||
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) + " SQLITE_CLIB_PATH=${pkgs.sqlite.out}/lib/libsqlite3.so " + "nvim"; | ||
|
||
programs.neovim = { | ||
enable = true; | ||
|
||
withNodeJs = true; | ||
withPython3 = true; | ||
withRuby = true; | ||
|
||
extraPackages = with pkgs; | ||
[ | ||
# Dependent packages used by default plugins | ||
doq | ||
sqlite | ||
] | ||
++ optionals cfg.withBuildTools [ | ||
pkg-config | ||
clang | ||
gcc | ||
cmake | ||
gnumake | ||
ninja | ||
cargo | ||
yarn | ||
] | ||
++ optionals cfg.withHaskell [ | ||
(pkgs.writeShellApplication { | ||
name = "stack"; | ||
text = '' | ||
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: [ | ||
# ghcup # ghcup is broken | ||
] ++ cfg.extraHaskellPackages pkgs.haskellPackages)) | ||
]; | ||
|
||
extraPython3Packages = ps: with ps; [ | ||
isort | ||
docformatter | ||
pynvim | ||
]; | ||
extraLuaPackages = ls: with ls; [ | ||
luarocks | ||
]; | ||
}; | ||
}; | ||
} |