aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/CODEOWNERS3
-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
-rw-r--r--tests/default.nix1
-rw-r--r--tests/modules/programs/ne/default.nix4
-rw-r--r--tests/modules/programs/ne/defprefs.nix30
-rw-r--r--tests/modules/programs/ne/passthroughs.nix70
9 files changed, 217 insertions, 0 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 3d27c518577..1995584a962 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -73,6 +73,9 @@
/modules/programs/mpv.nix @tadeokondrak
+/modules/programs/ne.nix @cwyc
+/tests/modules/programs/ne @cwyc
+
/modules/programs/noti.nix @marsam
/modules/programs/obs-studio.nix @adisbladis
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;
+ };
+}
diff --git a/tests/default.nix b/tests/default.nix
index f8bcc159e8a..4e9d05a3636 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -53,6 +53,7 @@ import nmt {
./modules/programs/lf
./modules/programs/lieer
./modules/programs/mbsync
+ ./modules/programs/ne
./modules/programs/neomutt
./modules/programs/newsboat
./modules/programs/qutebrowser
diff --git a/tests/modules/programs/ne/default.nix b/tests/modules/programs/ne/default.nix
new file mode 100644
index 00000000000..7a1c843d432
--- /dev/null
+++ b/tests/modules/programs/ne/default.nix
@@ -0,0 +1,4 @@
+{
+ ne-defprefs = ./defprefs.nix;
+ ne-passthroughs = ./passthroughs.nix;
+}
diff --git a/tests/modules/programs/ne/defprefs.nix b/tests/modules/programs/ne/defprefs.nix
new file mode 100644
index 00000000000..d1dc7232d3a
--- /dev/null
+++ b/tests/modules/programs/ne/defprefs.nix
@@ -0,0 +1,30 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+ defpref = ''
+ defined through defaultPreferences
+ '';
+ autopref = ''
+ defined through automaticPreferences
+ '';
+in {
+ config = {
+ programs.ne = {
+ enable = true;
+ defaultPreferences = defpref;
+ automaticPreferences.".default" = autopref;
+ };
+ nmt = {
+ description =
+ "Check that it gracefully handles the case of both defaultPreferences and automaticPreferences.'.default' being set, defaulting to the former.";
+ script = ''
+ assertFileExists home-files/.ne/.default#ap
+ assertFileContent home-files/.ne/.default#ap ${
+ builtins.toFile "defpref" defpref
+ }
+ '';
+
+ };
+ };
+}
diff --git a/tests/modules/programs/ne/passthroughs.nix b/tests/modules/programs/ne/passthroughs.nix
new file mode 100644
index 00000000000..5dc6aef0c0c
--- /dev/null
+++ b/tests/modules/programs/ne/passthroughs.nix
@@ -0,0 +1,70 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ # Samples taken from the ne manual.
+ keybindings = ''
+ SEQ "\x1b[1;5D" 14A
+ KEY 14A HELP
+ '';
+
+ menus = ''
+ MENU "File"
+ ITEM "Open... ^O" Open
+ ITEM "Close " Close
+ ITEM "DoIt " Macro DoIt
+ '';
+
+ virtualExtensions = ''
+ sh 1 ^#!\s*/.*\b(bash|sh|ksh|zsh)\s*
+ csh 1 ^#!\s*/.*\b(csh|tcsh)\s*
+ pl 1 ^#!\s*/.*\bperl\b
+ py 1 ^#!\s*/.*\bpython[0-9]*\s*
+ rb 1 ^#!\s*/.*\bruby\s*
+ xml 1 ^<\?xml
+ '';
+
+ automaticPreferences = {
+ nix = ''
+ TAB 0
+ TS 2
+ '';
+ js = ''
+ TS 4
+ '';
+ };
+
+ checkFile = filename: contents: ''
+ assertFileExists home-files/.ne/${filename}
+ assertFileContent home-files/.ne/${filename} ${
+ builtins.toFile "checkFile" contents
+ }
+ '';
+
+in {
+ config = {
+ programs.ne = {
+ enable = true;
+ inherit keybindings;
+ inherit menus;
+ inherit virtualExtensions;
+ inherit automaticPreferences;
+ };
+
+ nmt = {
+ description = "Check that configuration files are correctly written";
+ script = concatStringsSep "\n" [
+ (checkFile ".keys" keybindings)
+ (checkFile ".extensions" virtualExtensions)
+ (checkFile ".menus" menus)
+
+ # Generates a check command for each entry in automaticPreferences.
+ (concatStringsSep "\n" (mapAttrsToList
+ (extension: contents: checkFile "${extension}#ap" contents)
+ automaticPreferences))
+ ];
+ };
+ };
+}