mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-08 10:19:48 +01:00
Compare commits
2 commits
da26ea78b2
...
eb132eec36
Author | SHA1 | Date | |
---|---|---|---|
|
eb132eec36 | ||
|
6dc07ba5c1 |
4 changed files with 19 additions and 63 deletions
|
@ -42,7 +42,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosModules = {
|
nixosModules = {
|
||||||
nvf = import ./flake/modules/nixos.nix self.packages lib;
|
nvf = import ./flake/modules/nixos.nix self.packages lib inputs;
|
||||||
default = self.nixosModules.nvf;
|
default = self.nixosModules.nvf;
|
||||||
neovim-flake =
|
neovim-flake =
|
||||||
lib.warn ''
|
lib.warn ''
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# NixOS module
|
# NixOS module
|
||||||
packages: lib: {
|
packages: lib: inputs: {
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
|
@ -8,15 +8,19 @@ packages: lib: {
|
||||||
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
|
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
|
||||||
inherit (lib.lists) optional;
|
inherit (lib.lists) optional;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.types) attrsOf anything bool;
|
inherit (lib.types) anything bool submoduleWith;
|
||||||
inherit (lib.nvim) neovimConfiguration;
|
|
||||||
inherit (lib.nvim.types) anythingConcatLists;
|
|
||||||
|
|
||||||
cfg = config.programs.nvf;
|
cfg = config.programs.nvf;
|
||||||
|
|
||||||
neovimConfigured = neovimConfiguration {
|
nvfModule = submoduleWith {
|
||||||
inherit pkgs;
|
description = "Nvf module";
|
||||||
modules = [cfg.settings];
|
class = "nvf";
|
||||||
|
specialArgs = {
|
||||||
|
inherit pkgs lib inputs;
|
||||||
|
};
|
||||||
|
modules = [
|
||||||
|
{imports = import ../../modules/modules.nix {inherit pkgs lib;};}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -55,7 +59,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = attrsOf anythingConcatLists;
|
type = nvfModule;
|
||||||
default = {};
|
default = {};
|
||||||
description = "Attribute set of nvf preferences.";
|
description = "Attribute set of nvf preferences.";
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
|
@ -78,7 +82,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.nvf.finalPackage = neovimConfigured.neovim;
|
programs.nvf.finalPackage = config.programs.nvf.settings.vim.build.finalPackage;
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
|
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
|
||||||
|
|
|
@ -1,57 +1,9 @@
|
||||||
{lib}: let
|
{lib}: let
|
||||||
inherit (lib.options) showOption showFiles getFiles mergeOneOption mergeEqualOption;
|
inherit (lib.options) mergeEqualOption;
|
||||||
inherit (lib.strings) isString isStringLike;
|
inherit (lib.strings) isString;
|
||||||
inherit (lib.types) anything attrsOf listOf mkOptionType;
|
inherit (lib.types) listOf mkOptionType;
|
||||||
inherit (lib.nvim.types) anythingConcatLists;
|
inherit (builtins) stringLength match;
|
||||||
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
|
|
||||||
in {
|
in {
|
||||||
# HACK: Does this break anything in our case?
|
|
||||||
# A modified version of the nixpkgs anything type that concatenates lists
|
|
||||||
# This isn't the default because the order in which the lists are concatenated depends on the order in which the modules are imported,
|
|
||||||
# which makes it non-deterministic
|
|
||||||
anythingConcatLists =
|
|
||||||
anything
|
|
||||||
// {
|
|
||||||
merge = loc: defs: let
|
|
||||||
getType = value:
|
|
||||||
if isAttrs value && isStringLike value
|
|
||||||
then "stringCoercibleSet"
|
|
||||||
else typeOf value;
|
|
||||||
|
|
||||||
# Throw an error if not all defs have the same type
|
|
||||||
checkType = getType (head defs).value;
|
|
||||||
commonType =
|
|
||||||
if any (def: getType def.value != checkType) defs
|
|
||||||
then throw "The option `${showOption loc}' has conflicting option types in ${showFiles (getFiles defs)}"
|
|
||||||
else checkType;
|
|
||||||
|
|
||||||
mergeFunctions = {
|
|
||||||
# Recursively merge attribute sets
|
|
||||||
set = (attrsOf anythingConcatLists).merge;
|
|
||||||
|
|
||||||
# Overridden behavior for lists, that concatenates lists
|
|
||||||
list = _: defs: concatLists (map (e: e.value) defs);
|
|
||||||
|
|
||||||
# This means it's a package, only accept a single definition
|
|
||||||
stringCoercibleSet = mergeOneOption;
|
|
||||||
|
|
||||||
# This works by passing the argument to the functions,
|
|
||||||
# and merging their returns values instead
|
|
||||||
lambda = loc: defs: arg:
|
|
||||||
anythingConcatLists.merge
|
|
||||||
(loc ++ ["<function body>"])
|
|
||||||
(map (def: {
|
|
||||||
inherit (def) file;
|
|
||||||
value = def.value arg;
|
|
||||||
})
|
|
||||||
defs);
|
|
||||||
};
|
|
||||||
in
|
|
||||||
# Merge the defs with the correct function from above, if available
|
|
||||||
# otherwise only allow equal values
|
|
||||||
(mergeFunctions.${commonType} or mergeEqualOption) loc defs;
|
|
||||||
};
|
|
||||||
|
|
||||||
mergelessListOf = elemType: let
|
mergelessListOf = elemType: let
|
||||||
super = listOf elemType;
|
super = listOf elemType;
|
||||||
in
|
in
|
||||||
|
|
|
@ -11,5 +11,5 @@ in {
|
||||||
inherit (typesDag) dagOf;
|
inherit (typesDag) dagOf;
|
||||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
||||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||||
inherit (customTypes) anythingConcatLists char hexColor mergelessListOf;
|
inherit (customTypes) char hexColor mergelessListOf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue