diff --git a/extra.nix b/extra.nix new file mode 100644 index 0000000..bd5e705 --- /dev/null +++ b/extra.nix @@ -0,0 +1,168 @@ +inputs: let + modulesWithInputs = import ./modules {inherit inputs;}; + + neovimConfiguration = { + modules ? [], + pkgs, + lib ? pkgs.lib, + check ? true, + extraSpecialArgs ? {}, + }: + modulesWithInputs { + inherit pkgs lib check extraSpecialArgs; + configuration = {...}: { + imports = modules; + }; + }; + + mainConfig = isMaximal: { + config = { + vim = { + viAlias = true; + vimAlias = true; + }; + + vim.lsp = { + enable = true; + formatOnSave = true; + lightbulb.enable = true; + lspsaga.enable = false; + nvimCodeActionMenu.enable = true; + trouble.enable = true; + lspSignature.enable = true; + rust.enable = isMaximal; + python = isMaximal; + clang.enable = isMaximal; + sql = isMaximal; + ts = isMaximal; + go = isMaximal; + zig.enable = isMaximal; + nix = { + enable = true; + formatter = "alejandra"; + }; + }; + + vim.visuals = { + enable = true; + nvimWebDevicons.enable = true; + scrollBar.enable = true; + smoothScroll.enable = true; + cellularAutomaton.enable = true; + lspkind.enable = true; + indentBlankline = { + enable = true; + fillChar = ""; + eolChar = ""; + showCurrContext = true; + }; + cursorWordline = { + enable = true; + lineTimeout = 0; + }; + }; + + vim.statusline.lualine = { + enable = true; + theme = "catppuccin"; + }; + + vim.theme = { + enable = true; + name = "catppuccin"; + style = "mocha"; + }; + vim.autopairs.enable = true; + + vim.autocomplete = { + enable = true; + type = "nvim-cmp"; + }; + + vim.filetree = { + nvimTreeLua = { + enable = true; + view = { + width = 25; + }; + }; + }; + + vim.tabline = { + nvimBufferline.enable = true; + }; + + vim.treesitter = { + enable = true; + context.enable = true; + }; + + vim.binds = { + whichKey.enable = true; + cheatsheet.enable = true; + }; + + vim.telescope = { + enable = true; + }; + + vim.markdown = { + enable = true; + glow.enable = true; + }; + + vim.git = { + enable = true; + gitsigns.enable = true; + }; + + vim.minimap = { + minimap-vim.enable = false; + codewindow.enable = true; # lighter, faster, and uses lua for configuration + }; + + vim.dashboard = { + dashboard-nvim.enable = false; + alpha.enable = true; + }; + + vim.notify = { + nvim-notify.enable = true; + }; + + vim.utility = { + colorizer.enable = true; + icon-picker.enable = true; + venn-nvim.enable = false; # FIXME throws an error when its commands are ran manually + }; + + vim.notes = { + obsidian.enable = false; # FIXME neovim fails to build if obsidian is enabled + orgmode.enable = true; + }; + + vim.terminal = { + toggleterm.enable = true; + }; + + vim.ui = { + noice.enable = true; + }; + + vim.assistant = { + copilot.enable = false; + tabnine.enable = false; # FIXME: this is not working because the plugin depends on an internal script to be ran by the package manager + }; + + vim.session = { + nvim-session-manager.enable = false; + }; + + vim.gestures = { + gesture-nvim.enable = false; + }; + }; + }; +in { + inherit neovimConfiguration mainConfig; +} diff --git a/flake.lock b/flake.lock index 0c74fd2..97fc37c 100644 --- a/flake.lock +++ b/flake.lock @@ -305,6 +305,24 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1675295133, + "narHash": "sha256-dU8fuLL98WFXG0VnRgM00bqKX6CEPBLybhiIDIgO45o=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "bf53492df08f3178ce85e0c9df8ed8d03c030c9f", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -557,6 +575,24 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1672350804, + "narHash": "sha256-jo6zkiCabUBn3ObuKXHGqqORUMH27gYDIFFfLq5P4wg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "677ed08a50931e38382dbef01cba08a8f7eac8f6", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1656753965, @@ -1014,6 +1050,7 @@ "dashboard-nvim": "dashboard-nvim", "discord-nvim": "discord-nvim", "dressing-nvim": "dressing-nvim", + "flake-parts": "flake-parts", "flake-utils": "flake-utils", "gesture-nvim": "gesture-nvim", "gitsigns-nvim": "gitsigns-nvim", diff --git a/flake.nix b/flake.nix index 18cdb89..287688d 100644 --- a/flake.nix +++ b/flake.nix @@ -2,26 +2,11 @@ description = "A neovim flake with a modular configuration"; outputs = { nixpkgs, - flake-utils, + flake-parts, ... } @ inputs: let - modulesWithInputs = import ./modules {inherit inputs;}; - - neovimConfiguration = { - modules ? [], - pkgs, - lib ? pkgs.lib, - check ? true, - extraSpecialArgs ? {}, - }: - modulesWithInputs { - inherit pkgs lib check extraSpecialArgs; - configuration = {...}: { - imports = modules; - }; - }; - - nvimBin = pkg: "${pkg}/bin/nvim"; + inherit (nixpkgs) lib; + inherit (import ./extra.nix inputs) neovimConfiguration mainConfig; buildPkg = pkgs: modules: (neovimConfiguration { @@ -30,179 +15,42 @@ .neovim; tidalConfig = { - config = { - vim.tidal.enable = true; - }; - }; - - mainConfig = isMaximal: { - config = { - vim = { - viAlias = true; - vimAlias = true; - }; - - vim.lsp = { - enable = true; - formatOnSave = true; - lightbulb.enable = true; - lspsaga.enable = false; - nvimCodeActionMenu.enable = true; - trouble.enable = true; - lspSignature.enable = true; - rust.enable = isMaximal; - python = isMaximal; - clang.enable = isMaximal; - sql = isMaximal; - ts = isMaximal; - go = isMaximal; - zig.enable = isMaximal; - nix = { - enable = true; - formatter = "alejandra"; - }; - }; - - vim.visuals = { - enable = true; - nvimWebDevicons.enable = true; - scrollBar.enable = true; - smoothScroll.enable = true; - cellularAutomaton.enable = true; - lspkind.enable = true; - indentBlankline = { - enable = true; - fillChar = ""; - eolChar = ""; - showCurrContext = true; - }; - cursorWordline = { - enable = true; - lineTimeout = 0; - }; - }; - - vim.statusline.lualine = { - enable = true; - theme = "catppuccin"; - }; - - vim.theme = { - enable = true; - name = "catppuccin"; - style = "mocha"; - }; - vim.autopairs.enable = true; - - vim.autocomplete = { - enable = true; - type = "nvim-cmp"; - }; - - vim.filetree = { - nvimTreeLua = { - enable = true; - view = { - width = 25; - }; - }; - }; - - vim.tabline = { - nvimBufferline.enable = true; - }; - - vim.treesitter = { - enable = true; - context.enable = true; - }; - - vim.binds = { - whichKey.enable = true; - cheatsheet.enable = true; - }; - - vim.telescope = { - enable = true; - }; - - vim.markdown = { - enable = true; - glow.enable = true; - }; - - vim.git = { - enable = true; - gitsigns.enable = true; - }; - - vim.minimap = { - minimap-vim.enable = false; - codewindow.enable = true; # lighter, faster, and uses lua for configuration - }; - - vim.dashboard = { - dashboard-nvim.enable = false; - alpha.enable = true; - }; - - vim.notify = { - nvim-notify.enable = true; - }; - - vim.utility = { - colorizer.enable = true; - icon-picker.enable = true; - venn-nvim.enable = false; # FIXME throws an error when its commands are ran manually - }; - - vim.notes = { - obsidian.enable = false; # FIXME neovim fails to build if obsidian is enabled - orgmode.enable = true; - }; - - vim.terminal = { - toggleterm.enable = true; - }; - - vim.ui = { - noice.enable = true; - }; - - vim.assistant = { - copilot.enable = false; - tabnine.enable = false; # FIXME: this is not working because the plugin depends on an internal script to be ran by the package manager - }; - - vim.session = { - nvim-session-manager.enable = false; - }; - - vim.gestures = { - gesture-nvim.enable = false; - }; - }; + config.vim.tidal.enable = true; }; nixConfig = mainConfig false; maximalConfig = mainConfig true; in - { - lib = { - nvim = (import ./lib/stdlib-extended.nix nixpkgs.lib).nvim; - inherit neovimConfiguration; + flake-parts.lib.mkFlake {inherit inputs;} { + systems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + + flake = { + lib = { + nvim = (import ./lib/stdlib-extended.nix nixpkgs.lib).nvim; + inherit neovimConfiguration; + }; + + overlays.default = final: prev: { + inherit neovimConfiguration; + neovim-nix = buildPkg prev [nixConfig]; + neovim-maximal = buildPkg prev [maximalConfig]; + neovim-tidal = buildPkg prev [tidalConfig]; + }; + + nixosModules.hm-module = { + imports = [ + ./lib/hm.nix + # {nixpkgs.overlays = [inputs.self.overlays.default];} what? + ]; + }; }; - overlays.default = final: prev: { - inherit neovimConfiguration; - neovim-nix = buildPkg prev [nixConfig]; - neovim-maximal = buildPkg prev [maximalConfig]; - neovim-tidal = buildPkg prev [tidalConfig]; - }; - } - // (flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = import nixpkgs { + perSystem = { + system, + self', + ... + }: { + legacyPackages = import nixpkgs { inherit system; overlays = [ inputs.tidalcycles.overlays.default @@ -213,42 +61,28 @@ ]; }; - docs = import ./docs { - inherit pkgs; - nmdSrc = inputs.nmd; - }; - - # Available Configurations - tidalPkg = buildPkg pkgs [tidalConfig]; - nixPkg = buildPkg pkgs [nixConfig]; - maximalPkg = buildPkg pkgs [maximalConfig]; - in { apps = - rec { - nix = { - type = "app"; - program = nvimBin nixPkg; - }; - maximal = { - type = "app"; - program = nvimBin maximalPkg; - }; - default = nix; + { + nix.program = lib.getExe self'.packages.nix; + maximal.program = lib.getExe self'.packages.maximal; + default = self'.apps.nix; } // ( if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"]) then { - tidal = { - type = "app"; - program = nvimBin tidalPkg; - }; + tidal.program = lib.getExe self'.packages.tidal; } else {} ); - devShells.default = pkgs.mkShell {nativeBuildInputs = [nixPkg];}; + devShells.default = self'.legacyPackages.mkShell {nativeBuildInputs = [self'.packages.nix];}; - packages = + packages = let + docs = import ./docs { + pkgs = self'.legacyPackages; + nmdSrc = inputs.nmd; + }; + in { # Documentation docs = docs.manual.html; @@ -257,31 +91,22 @@ docs-json = docs.options.json; # Available Configurations - default = nixPkg; - nix = nixPkg; - maximal = maximalPkg; + nix = buildPkg self'.legacyPackages [nixConfig]; + maximal = buildPkg self'.legacyPackages [maximalConfig]; } // ( if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"]) - then { - tidal = tidalPkg; - } + then {tidal = buildPkg self'.legacyPackages [tidalConfig];} else {} ); - - nixosModules.hm-module = { - imports = [ - ./lib/hm.nix - # {nixpkgs.overlays = [inputs.self.overlays.default];} what? - ]; - }; - } - )); + }; + }; # Flake inputs inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; + flake-parts.url = "github:hercules-ci/flake-parts"; # For generating documentation website nmd = {