nix-home/home/modules/programs/my-kakoune/default.nix

65 lines
1.6 KiB
Nix
Raw Permalink Normal View History

{ config, options, pkgs, lib, ... }:
2022-01-12 20:55:53 +00:00
with lib;
let
cfg = config.programs.my-kakoune;
in
{
imports = [ ./fish-session.nix ./tree-sitter.nix ];
2022-01-12 20:55:53 +00:00
options.programs.my-kakoune = {
enable = mkEnableOption "My version of the kakoune configuration";
package = mkOption {
type = types.package;
default = pkgs.nki-kakoune;
2022-01-12 20:55:53 +00:00
description = "The kakoune package to be installed";
};
rc = mkOption {
type = types.lines;
default = "";
description = "Content of the kakrc file. A line-concatenated string";
};
2023-06-30 11:38:46 +00:00
extraFaces = mkOption {
type = types.attrsOf types.str;
default = { };
description = "Extra faces to include";
};
autoloadFile = mkOption {
type = options.xdg.configFile.type;
default = { };
description = "Extra autoload files";
};
2022-01-12 20:55:53 +00:00
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile =
2022-01-12 20:55:53 +00:00
let
2023-06-30 11:38:46 +00:00
kakouneFaces =
let
txt = strings.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") cfg.extraFaces));
in
pkgs.writeText "faces.kak" txt;
2022-01-12 20:55:53 +00:00
in
{
"kak/autoload/builtin".source = "${cfg.package}/share/kak/autoload";
2022-01-12 20:55:53 +00:00
# kakrc
2023-06-30 11:38:46 +00:00
"kak/kakrc".text = ''
${cfg.rc}
# Load faces
source ${kakouneFaces}
'';
} // lib.mapAttrs'
(name: attrs: {
name = "kak/autoload/${name}";
value = attrs // {
target = "kak/autoload/${name}";
};
})
cfg.autoloadFile;
2022-01-12 20:55:53 +00:00
};
}