1
0
Fork 0
nix-configuration/modules/nixos/system/editor/default.nix

42 lines
768 B
Nix
Raw Normal View History

# Basic system-wide text editor configuration.
2024-12-06 18:04:47 +00:00
{
config,
lib,
namespace,
...
}:
let
2024-12-06 18:04:47 +00:00
cfg = config.${namespace}.editor;
in
{
options = {
2024-12-06 18:04:47 +00:00
${namespace}.editor = lib.mkOption {
description = "Selects the default text editor.";
default = "nano";
type = lib.types.enum [
"vim"
"nano"
"emacs"
];
};
};
config = lib.mkMerge [
(lib.mkIf (cfg == "emacs") {
services.emacs = {
enable = true;
defaultEditor = true;
};
})
(lib.mkIf (cfg == "nano") {
programs.nano = {
enable = true;
syntaxHighlight = true;
};
environment.variables."EDITOR" = "nano";
})
(lib.mkIf (cfg == "vim") { programs.vim.defaultEditor = true; })
];
}