forked from nix-community/nixvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This represents a major rearchitecture for nixvim, so I'm leaving this up to track the progress for now, and to serve as a reference for any breaking changes during transition. The main change is, of course, being able to use nixvim standalone. To do this, you should use the new build function, which takes in two arguments: the system architecture (e.g. x86_64-linux) and the configuration. For the new configuration, do not use the programs.nixvim. prefix. For module development, the main change is that you should no longer prefix your modules with programs.nixvim..
- Loading branch information
Showing
52 changed files
with
1,394 additions
and
888 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,102 +1,83 @@ | ||
{ | ||
description = "A neovim configuration system for NixOS"; | ||
|
||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
inputs.nmdSrc.url = "gitlab:rycee/nmd"; | ||
inputs.nmdSrc.flake = false; | ||
|
||
outputs = { self, nixpkgs, nmdSrc, ... }@inputs: rec { | ||
packages."x86_64-linux".docs = import ./docs { | ||
pkgs = import nixpkgs { system = "x86_64-linux"; }; | ||
lib = nixpkgs.lib; | ||
}; | ||
|
||
nixosModules.nixvim = import ./nixvim.nix { nixos = true; }; | ||
homeManagerModules.nixvim = import ./nixvim.nix { homeManager = true; }; | ||
|
||
# This is a simple container for testing | ||
nixosConfigurations.container = nixpkgs.lib.nixosSystem { | ||
system = "x86_64-linux"; | ||
modules = [ | ||
({ pkgs, ... }: { | ||
boot.isContainer = true; | ||
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; | ||
|
||
users.users.test = { | ||
isNormalUser = true; | ||
password = ""; | ||
}; | ||
|
||
imports = [ nixosModules.nixvim ]; | ||
|
||
programs.nixvim = { | ||
enable = true; | ||
package = pkgs.neovim; | ||
colorschemes.tokyonight = { enable = true; }; | ||
|
||
extraPlugins = [ pkgs.vimPlugins.vim-nix ]; | ||
|
||
options = { | ||
number = true; | ||
mouse = "a"; | ||
tabstop = 2; | ||
shiftwidth = 2; | ||
expandtab = true; | ||
smarttab = true; | ||
autoindent = true; | ||
cindent = true; | ||
linebreak = true; | ||
hidden = true; | ||
}; | ||
|
||
maps.normalVisualOp."ç" = ":"; | ||
maps.normal."<leader>m" = { | ||
silent = true; | ||
action = "<cmd>make<CR>"; | ||
}; | ||
|
||
plugins.lualine = { | ||
enable = true; | ||
# TODO: Use flake-utils to support all architectures | ||
outputs = { self, nixpkgs, nmdSrc, flake-utils, ... }@inputs: | ||
with nixpkgs.lib; | ||
with builtins; | ||
let | ||
# TODO: Support nesting | ||
nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules)); | ||
|
||
modules = pkgs: nixvimModules ++ [ | ||
(rec { | ||
_file = ./flake.nix; | ||
key = _file; | ||
config = { | ||
_module.args = { | ||
pkgs = mkForce pkgs; | ||
lib = pkgs.lib; | ||
helpers = import ./plugins/helpers.nix { lib = pkgs.lib; }; | ||
}; | ||
}; | ||
}) | ||
|
||
plugins.undotree.enable = true; | ||
plugins.gitgutter.enable = true; | ||
plugins.fugitive.enable = true; | ||
plugins.commentary.enable = true; | ||
plugins.startify = { | ||
enable = true; | ||
useUnicode = true; | ||
}; | ||
plugins.goyo = { | ||
enable = true; | ||
showLineNumbers = true; | ||
}; | ||
./plugins/default.nix | ||
]; | ||
|
||
plugins.lsp = { | ||
enable = true; | ||
servers.clangd.enable = true; | ||
nixvimOption = pkgs: mkOption { | ||
type = types.submodule ((modules pkgs) ++ [{ | ||
options.enable = mkEnableOption "Enable nixvim"; | ||
}]); | ||
}; | ||
|
||
build = pkgs: | ||
configuration: | ||
let | ||
eval = evalModules { | ||
modules = modules pkgs ++ [ configuration ]; | ||
}; | ||
in | ||
eval.config.output; | ||
|
||
flakeOutput = | ||
flake-utils.lib.eachDefaultSystem | ||
(system: rec { | ||
packages.docs = import ./docs { | ||
pkgs = import nixpkgs { inherit system; }; | ||
lib = nixpkgs.lib; | ||
nixvimModules = nixvimModules; | ||
inherit nmdSrc; | ||
}; | ||
|
||
plugins.telescope = { | ||
enable = true; | ||
extensions = { frecency.enable = true; }; | ||
nixosModules.nixvim = { pkgs, config, lib, ... }: { | ||
options.programs.nixvim = nixvimOption pkgs; | ||
config = mkIf config.programs.nixvim.enable { | ||
environment.systemPackages = [ | ||
config.programs.nixvim.output | ||
]; | ||
}; | ||
}; | ||
|
||
plugins.nvim-autopairs = { enable = true; }; | ||
|
||
globals = { | ||
vimsyn_embed = "l"; | ||
mapleader = " "; | ||
homeManagerModules.nixvim = { pkgs, config, lib, ... }: { | ||
options.programs.nixvim = nixvimOption pkgs; | ||
config = mkIf config.programs.nixvim.enable { | ||
home.packages = [ | ||
config.programs.nixvim.output | ||
]; | ||
}; | ||
}; | ||
|
||
plugins.lspsaga.enable = true; | ||
|
||
plugins.treesitter.enable = true; | ||
plugins.ledger.enable = true; | ||
}; | ||
}) | ||
]; | ||
}); | ||
in | ||
flakeOutput // { | ||
inherit build; | ||
# TODO: Stuff for home-manager and nixos modules backwards compat, keeping the architecture as x86_64 if none is specified... | ||
homeManagerModules.nixvim = flakeOutput.homeManagerModules.x86_64-linux.nixvim; | ||
nixosModules.nixvim = flakeOutput.nixosModules.x86_64-linux.nixvim; | ||
}; | ||
}; | ||
} |
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,17 @@ | ||
{ config, lib, ... }: | ||
with lib; | ||
{ | ||
options = { | ||
colorscheme = mkOption { | ||
type = types.nullOr types.str; | ||
description = "The name of the colorscheme to use"; | ||
default = null; | ||
}; | ||
}; | ||
|
||
config = { | ||
extraConfigVim = optionalString (config.colorscheme != "" && config.colorscheme != null) '' | ||
colorscheme ${config.colorscheme} | ||
''; | ||
}; | ||
} |
Oops, something went wrong.