nix-community.nixvim/flake.nix

96 lines
2.6 KiB
Nix
Raw Normal View History

2020-12-30 01:05:51 +00:00
{
description = "A neovim configuration system for NixOS";
inputs.flake-utils.url = "github:numtide/flake-utils";
2020-12-30 01:05:51 +00:00
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;
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;
inherit (pkgs) lib;
helpers = import ./plugins/helpers.nix { inherit (pkgs) lib; };
2021-01-05 11:26:49 +00:00
};
};
})
2021-01-07 16:06:39 +00:00
./plugins/default.nix
];
2021-02-01 15:54:53 +00:00
nixvimOption = pkgs: mkOption {
type = types.submodule ((modules pkgs) ++ [{
options.enable = mkEnableOption "Enable nixvim";
}]);
};
helperOption = pkgs: mkOption {
type = mkOptionType {
name = "helpers";
description = "Helpers that can be used when writing nixvim configs";
check = builtins.isAttrs;
};
description = "Use this option to access the helpers";
default = import ./plugins/helpers.nix { inherit (pkgs) lib; };
};
build = pkgs:
configuration:
let
eval = evalModules {
2022-10-03 15:21:28 +01:00
modules = modules pkgs ++ [{ config = 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;
2021-02-01 15:54:53 +00:00
};
});
in
flakeOutput // rec {
inherit build;
nixosModules.nixvim = { pkgs, config, lib, ... }: {
options = {
programs.nixvim = nixvimOption pkgs;
nixvim.helpers = helperOption pkgs;
};
config = mkIf config.programs.nixvim.enable {
environment.systemPackages = [
config.programs.nixvim.output
];
};
};
homeManagerModules.nixvim = { pkgs, config, lib, ... }: {
options = {
programs.nixvim = nixvimOption pkgs;
nixvim.helpers = helperOption pkgs;
};
config = mkIf config.programs.nixvim.enable {
home.packages = [
config.programs.nixvim.output
];
};
};
2020-12-30 01:05:51 +00:00
};
}