From 2823e5284ec989b0fadb9aec7e0af0c61310fa19 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Tue, 24 Dec 2024 20:55:07 -0800 Subject: [PATCH] feat: add default editor option and configuration --- hosts/demeter/configuration.nix | 1 + modules/linux/core/default.nix | 4 ---- modules/linux/misc/default.nix | 11 +++++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hosts/demeter/configuration.nix b/hosts/demeter/configuration.nix index cb24d82..7c2e507 100755 --- a/hosts/demeter/configuration.nix +++ b/hosts/demeter/configuration.nix @@ -19,6 +19,7 @@ liminalOS = { flakeLocation = "/home/youwen/.config/liminalOS"; config.allowUnfree = true; + defaultEditor = inputs.viminal.packages.${pkgs.system}.default; system = { audio.prod.enable = true; networking = { diff --git a/modules/linux/core/default.nix b/modules/linux/core/default.nix index 0991dba..4c8604e 100644 --- a/modules/linux/core/default.nix +++ b/modules/linux/core/default.nix @@ -84,10 +84,6 @@ in inputs.viminal.packages.${pkgs.system}.default ]; - environment.variables = { - EDITOR = "nvim"; - }; - # tells electron apps to use Wayland environment.sessionVariables = lib.mkIf cfg.waylandFixes { NIXOS_OZONE_WL = "1"; diff --git a/modules/linux/misc/default.nix b/modules/linux/misc/default.nix index a7c378e..7e93c75 100644 --- a/modules/linux/misc/default.nix +++ b/modules/linux/misc/default.nix @@ -50,6 +50,11 @@ in default = true; description = "Whether to use the en_US locale automatically"; }; + defaultEditor = lib.mkOption { + type = lib.types.nullOr lib.types.package; + default = pkgs.neovim; + description = "Default text editor that will be installed and set as $EDITOR. Set to null to disable setting and installing default text editor."; + }; }; config = { @@ -86,6 +91,12 @@ in ) ); + environment.variables.EDITOR = lib.mkIf ( + cfg.defaultEditor != null + ) cfg.defaultEditor.meta.mainProgram; + + environment.systemPackages = lib.mkIf (cfg.defaultEditor != null) [ cfg.defaultEditor ]; + # Select internationalisation properties. i18n = lib.mkIf cfg.useEnUsLocale { defaultLocale = "en_US.UTF-8";