From 0e1b0a36d16447a6fd53642b3eb5cff11c06221c Mon Sep 17 00:00:00 2001 From: Chris Kruining Date: Tue, 23 Jul 2024 19:42:03 +0200 Subject: [PATCH] . --- modules/_programs/shell.nix | 15 +----------- modules/desktop/editors/default.nix | 38 +++++++++++++++++++++++++++++ modules/desktop/editors/nano.nix | 27 ++++++++++++++++++++ 3 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 modules/desktop/editors/default.nix create mode 100644 modules/desktop/editors/nano.nix diff --git a/modules/_programs/shell.nix b/modules/_programs/shell.nix index cd8a254..29fc9fd 100644 --- a/modules/_programs/shell.nix +++ b/modules/_programs/shell.nix @@ -36,18 +36,5 @@ programs.zsh.enable = true; programs.starship.enable = true; - programs.nano = { - enable = true; - syntaxHighlight = true; - nanorc = '' - set autoindent - set jumpyscrolling - set linenumbers - set mouse - set saveonexit - set smarthome - set tabstospaces - set tabsize 2 - ''; - }; + } diff --git a/modules/desktop/editors/default.nix b/modules/desktop/editors/default.nix new file mode 100644 index 0000000..736aeb2 --- /dev/null +++ b/modules/desktop/editors/default.nix @@ -0,0 +1,38 @@ +{ + config, + options, + lib, + pkgs, + ... +}: let + inherit (lib.attrsets) attrValues; + inherit (lib.modules) mkIf mkMerge; + cfg = config.modules.desktop.editors; +in { + options.modules.desktop.editors = let + inherit (lib.options) mkOption; + inherit (lib.types) nullOr enum; + in { + default = mkOption { + type = nullOr (enum [ "nano" "nvim" ]); + default = "nano"; + description = "Default editor for text manipulation"; + example = "nvim"; + }; + }; + + config = mkMerge [ + (mkIf (cfg.default != null) { + home.sessionVariables = { + EDITOR = cfg.default; + }; + }) + + (mkIf (cfg.default == "nvim") { + user.packages = attrValues { + inherit (pkgs) imagemagick editorconfig-core-c sqlite deno pandoc nuspell; + inherit (pkgs.hunspellDicts) en_GB nl_NL; + }; + }) + ]; +} diff --git a/modules/desktop/editors/nano.nix b/modules/desktop/editors/nano.nix new file mode 100644 index 0000000..2ade641 --- /dev/null +++ b/modules/desktop/editors/nano.nix @@ -0,0 +1,27 @@ +{ config, options, lib, pkgs, ... }: +let + inherit (lib.meta) getExe; + inherit (lib.modules) mkIf; +in +{ + options.modules.desktop.editors.nano = let + inherit (lib.options) mkEnableOption; + in { enable = mkEnableOption "nano"; }; + + config = mkIf config.modules.desktop.editors.nano.enable { + programs.nano = { + enable = true; + syntaxHighlight = true; + nanorc = '' + set autoindent + set jumpyscrolling + set linenumbers + set mouse + set saveonexit + set smarthome + set tabstospaces + set tabsize 2 + ''; + }; + }; +}