diff --git a/flake.nix b/flake.nix index 88d8d030..37d8ed21 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,6 @@ inputs.nmdSrc.url = "gitlab:rycee/nmd"; inputs.nmdSrc.flake = false; - # TODO: Use flake-utils to support all architectures outputs = { self, nixpkgs, nmdSrc, flake-utils, ... }@inputs: with nixpkgs.lib; with builtins; @@ -30,24 +29,11 @@ ./plugins/default.nix ]; - nixvimOption = pkgs: mkOption { - type = types.submodule ((modules pkgs) ++ [{ - options.enable = mkEnableOption "Enable nixvim"; - }]); - }; - - build = pkgs: - configuration: - let - eval = evalModules { - modules = modules pkgs ++ [{ config = configuration; }]; - }; - in - eval.config.output; - flakeOutput = flake-utils.lib.eachDefaultSystem - (system: rec { + (system: let + pkgs = import nixpkgs { inherit system; }; + in { packages.docs = import ./docs { pkgs = import nixpkgs { inherit system; }; lib = nixpkgs.lib; @@ -55,28 +41,11 @@ inherit nmdSrc; }; - nixosModules.nixvim = { pkgs, config, lib, ... }: { - options.programs.nixvim = nixvimOption pkgs; - config = mkIf config.programs.nixvim.enable { - environment.systemPackages = [ - config.programs.nixvim.output - ]; - }; - }; - - homeManagerModules.nixvim = { pkgs, config, lib, ... }: { - options.programs.nixvim = nixvimOption pkgs; - config = mkIf config.programs.nixvim.enable { - home.packages = [ - config.programs.nixvim.output - ]; - }; - }; + legacyPackages.makeNixvim = import ./wrappers/standalone.nix pkgs (modules pkgs); }); in flakeOutput // { - inherit build; - homeManagerModules.nixvim = flakeOutput.homeManagerModules.x86_64-linux.nixvim; - nixosModules.nixvim = flakeOutput.nixosModules.x86_64-linux.nixvim; + nixosModules.nixvim = import ./wrappers/nixos.nix modules; + homeManagerModules.nixvim = import ./wrappers/hm.nix modules; }; } diff --git a/modules/output.nix b/modules/output.nix index 2f2fc297..3db8120f 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -65,9 +65,21 @@ in description = "Extra contents for init.vim"; }; - output = mkOption { + wrapRc = mkOption { + type = types.bool; + description = "Should the config be included in the wrapper script"; + default = false; + }; + + finalPackage = mkOption { type = types.package; - description = "Final package built by nixvim"; + description = "Wrapped neovim"; + readOnly = true; + }; + + initContent = mkOption { + type = types.str; + description = "The content of the init.vim file"; readOnly = true; visible = false; }; @@ -113,9 +125,10 @@ in wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig // { wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs; + inherit (config) wrapRc; }); - in - { - output = wrappedNeovim; + in { + finalPackage = wrappedNeovim; + initContent = neovimConfig.neovimRcContent; }; } diff --git a/nixvim.nix b/nixvim.nix deleted file mode 100644 index 09b06e45..00000000 --- a/nixvim.nix +++ /dev/null @@ -1,306 +0,0 @@ -{ nixos ? false, nixOnDroid ? false, homeManager ? false }: -{ pkgs, lib, config, ... }: -with lib; -let - cfg = config.programs.nixvim; - - pluginWithConfigType = types.submodule { - options = { - config = mkOption { - type = types.lines; - description = "vimscript for this plugin to be placed in init.vim"; - default = ""; - }; - - optional = mkEnableOption "optional" // { - description = "Don't load by default (load with :packadd)"; - }; - - plugin = mkOption { - type = types.package; - description = "vim plugin"; - }; - }; - }; - - mapOption = types.oneOf [ - types.str - (types.submodule { - options = { - silent = mkOption { - type = types.bool; - description = "Whether this mapping should be silent. Equivalent to adding to a map."; - default = false; - }; - - nowait = mkOption { - type = types.bool; - description = "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; - default = false; - }; - - script = mkOption { - type = types.bool; - description = "Equivalent to adding