Restructure kakoune configuration

This commit is contained in:
Natsu Kagami 2022-01-12 15:55:53 -05:00
parent 801622b7be
commit d5989c525c
Signed by: nki
GPG key ID: 7306B3D3C3AD6E51
5 changed files with 135 additions and 82 deletions

View file

@ -0,0 +1,67 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.my-kakoune;
autoloadModule = types.submodule {
options = {
name = mkOption {
type = types.str;
description = "Name of the autoload script/folder. It might affect kakoune's load order.";
};
src = mkOption {
type = types.path;
description = "Path to the autoload script/folder.";
};
};
};
in
{
imports = [ ./kak-lsp.nix ];
options.programs.my-kakoune = {
enable = mkEnableOption "My version of the kakoune configuration";
package = mkOption {
type = types.package;
default = pkgs.kakoune;
description = "The kakoune package to be installed";
};
rc = mkOption {
type = types.lines;
default = "";
description = "Content of the kakrc file. A line-concatenated string";
};
autoload = mkOption {
type = types.listOf autoloadModule;
default = [ ];
description = "Sources to autoload";
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.file =
let
kakouneAutoload = { name, src }: {
name = "kakoune/autoload/${name}";
value = {
source = src;
target = ".config/kak/autoload/${name}";
};
};
in
{
# kakrc
".config/kak/kakrc".text = cfg.rc;
} //
(builtins.listToAttrs (map kakouneAutoload ([
# include the original autoload files
{
name = "rc";
src = "${cfg.package}/share/kak/autoload";
}
] ++ cfg.autoload)));
};
}