aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorcwyc <cwyc@users.noreply.github.com>2020-06-15 21:47:58 -0400
committerRobert Helgesson <robert@rycee.net>2020-06-23 22:37:02 +0200
commit8f2342e13a2ddc84ed5053e2bfc393184258c686 (patch)
tree76f286c42e9be4b1f7ecb8d58f4207558dce38dd /modules
parent8ab113989126d738691ad70394ad5d0a57dab462 (diff)
ne: add module
Added a simple module to place configuration files for ne: the nice editor. PR #1336
Diffstat (limited to 'modules')
-rw-r--r--modules/lib/maintainers.nix6
-rw-r--r--modules/misc/news.nix7
-rw-r--r--modules/modules.nix1
-rw-r--r--modules/programs/ne.nix95
4 files changed, 109 insertions, 0 deletions
diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix
index 93d9f1fa84c..49d14ef0638 100644
--- a/modules/lib/maintainers.nix
+++ b/modules/lib/maintainers.nix
@@ -19,4 +19,10 @@
github = "owm111";
githubId = 7798336;
};
+ cwyc = {
+ email = "cwyc@users.noreply.github.com";
+ name = "cwyc";
+ github = "cwyc";
+ githubId = 16950437;
+ };
}
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index f45be6d6d8a..3009ae7bb32 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -1597,6 +1597,13 @@ in
Apologies for the belated notification!
'';
}
+
+ {
+ time = "2020-06-23T20:06:39+00:00";
+ message = ''
+ A new module is available: 'programs.ne'
+ '';
+ }
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index 14628c767b6..a7054f38179 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -89,6 +89,7 @@ let
(loadModule ./programs/mercurial.nix { })
(loadModule ./programs/mpv.nix { })
(loadModule ./programs/msmtp.nix { })
+ (loadModule ./programs/ne.nix { })
(loadModule ./programs/neomutt.nix { })
(loadModule ./programs/neovim.nix { })
(loadModule ./programs/newsboat.nix { })
diff --git a/modules/programs/ne.nix b/modules/programs/ne.nix
new file mode 100644
index 00000000000..a88d23d9133
--- /dev/null
+++ b/modules/programs/ne.nix
@@ -0,0 +1,95 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ cfg = config.programs.ne;
+
+ autoPrefFiles = let
+ autoprefs = cfg.automaticPreferences
+ // optionalAttrs (cfg.defaultPreferences != "") {
+ ".default" = cfg.defaultPreferences;
+ };
+
+ gen = fileExtension: configText:
+ nameValuePair ".ne/${fileExtension}#ap" {
+ text = configText;
+ }; # Generates [path].text format expected by home.file.
+ in mapAttrs' gen autoprefs;
+
+in {
+ meta.maintainers = [ hm.maintainers.cwyc ];
+
+ options.programs.ne = {
+ enable = mkEnableOption "ne";
+
+ keybindings = mkOption {
+ type = types.lines;
+ default = "";
+ example = ''
+ KEY 7f BS
+ SEQ "\x1b[1;5D" 7f
+ '';
+ description = ''
+ Keybinding file for ne.
+ '';
+ };
+
+ defaultPreferences = mkOption {
+ type = types.lines;
+ default = "";
+ description = ''
+ Default preferences for ne.
+ </para><para>
+ Equivalent to <literal>programs.ne.automaticPreferences.".default"</literal>.
+ '';
+ };
+
+ automaticPreferences = mkOption {
+ type = types.attrsOf types.lines;
+ default = { };
+ example = literalExample ''
+ {
+ nix = '''
+ TAB 0
+ TS 2
+ ''';
+ js = '''
+ TS 4
+ ''';
+ }
+ '';
+ description = ''
+ Automatic preferences files for ne.
+ '';
+ };
+
+ menus = mkOption {
+ type = types.lines;
+ default = "";
+ description = "Menu configuration file for ne.";
+ };
+
+ virtualExtensions = mkOption {
+ type = types.lines;
+ default = "";
+ example = ''
+ sh 1 ^#!\s*/.*\b(bash|sh|ksh|zsh)\s*
+ csh 1 ^#!\s*/.*\b(csh|tcsh)\s*
+ '';
+ description = "Virtual extensions configuration file for ne.";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ home.packages = [ pkgs.ne ];
+
+ home.file = {
+ ".ne/.keys" = mkIf (cfg.keybindings != "") { text = cfg.keybindings; };
+ ".ne/.extensions" =
+ mkIf (cfg.virtualExtensions != "") { text = cfg.virtualExtensions; };
+ ".ne/.menus" = mkIf (cfg.menus != "") { text = cfg.menus; };
+ } // autoPrefFiles;
+ };
+}