diff --git a/modules/programs/anvil-editor.nix b/modules/programs/anvil-editor.nix new file mode 100644 index 000000000..f075259d4 --- /dev/null +++ b/modules/programs/anvil-editor.nix @@ -0,0 +1,75 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.anvil-editor; + tomlFormat = pkgs.formats.toml { }; + jsonFormat = pkgs.formats.json { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + options.programs.anvil-editor = { + enable = mkEnableOption "anvil-editor"; + package = mkPackageOption pkgs "anvil-editor" { nullable = true; }; + settings = mkOption { + inherit (tomlFormat) type; + default = { }; + example = { + general.exec = [ + "aad" + "ado" + ]; + layout.column-tag = "New Cut Paste Snarf Zerox Delcol"; + typesetting.replace-cr-with-tofu = false; + env = { + FOO = "BAR"; + BAR = "FOO"; + }; + }; + description = '' + Configuration settings for anvil-editor. All available options can be found here: + . + ''; + }; + style = mkOption { + inherit (jsonFormat) type; + default = { }; + example = { + TagFgColor = "#fefefe"; + TagBgColor = "#263859"; + BodyBgColor = "#17223b"; + ScrollFgColor = "#17223b"; + ScrollBgColor = "#6b778d"; + GutterWidth = 14; + WinBorderColor = "#000000"; + }; + description = '' + Style settings for anvil-editor. All available options can be found here: + . + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + home.file = { + ".anvil/settings.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "anvil-settings.toml" cfg.settings; + }; + + ".anvil/style.js" = mkIf (cfg.style != { }) { + source = jsonFormat.generate "anvil-style.js" cfg.style; + }; + }; + }; +} diff --git a/tests/darwinScrublist.nix b/tests/darwinScrublist.nix index be5076a5a..1287f6812 100644 --- a/tests/darwinScrublist.nix +++ b/tests/darwinScrublist.nix @@ -11,6 +11,7 @@ let "alacritty" "alot" "antidote" + "anvil-editor" "aria2" "atuin" "autojump" diff --git a/tests/modules/programs/anvil-editor/default.nix b/tests/modules/programs/anvil-editor/default.nix new file mode 100644 index 000000000..c5b5e4e26 --- /dev/null +++ b/tests/modules/programs/anvil-editor/default.nix @@ -0,0 +1 @@ +{ anvil-editor-settings = ./settings.nix; } diff --git a/tests/modules/programs/anvil-editor/settings.nix b/tests/modules/programs/anvil-editor/settings.nix new file mode 100644 index 000000000..6dea38b4e --- /dev/null +++ b/tests/modules/programs/anvil-editor/settings.nix @@ -0,0 +1,37 @@ +{ + programs.anvil-editor = { + enable = true; + settings = { + general.exec = [ + "aad" + "ado" + ]; + layout.column-tag = "New Cut Paste Snarf Zerox Delcol"; + typesetting.replace-cr-with-tofu = false; + env = { + FOO = "BAR"; + BAR = "FOO"; + }; + }; + + style = { + TagFgColor = "#fefefe"; + TagBgColor = "#263859"; + BodyBgColor = "#17223b"; + ScrollFgColor = "#17223b"; + ScrollBgColor = "#6b778d"; + GutterWidth = 14; + WinBorderColor = "#000000"; + }; + }; + + nmt.script = '' + assertFileExists home-files/.anvil/settings.toml + assertFileExists home-files/.anvil/style.js + + assertFileContent home-files/.anvil/settings.toml \ + ${./settings.toml} + assertFileContent home-files/.anvil/style.js \ + ${./style.js} + ''; +} diff --git a/tests/modules/programs/anvil-editor/settings.toml b/tests/modules/programs/anvil-editor/settings.toml new file mode 100644 index 000000000..a3d1a34af --- /dev/null +++ b/tests/modules/programs/anvil-editor/settings.toml @@ -0,0 +1,12 @@ +[env] +BAR = "FOO" +FOO = "BAR" + +[general] +exec = ["aad", "ado"] + +[layout] +column-tag = "New Cut Paste Snarf Zerox Delcol" + +[typesetting] +replace-cr-with-tofu = false diff --git a/tests/modules/programs/anvil-editor/style.js b/tests/modules/programs/anvil-editor/style.js new file mode 100644 index 000000000..37fdcca52 --- /dev/null +++ b/tests/modules/programs/anvil-editor/style.js @@ -0,0 +1,9 @@ +{ + "BodyBgColor": "#17223b", + "GutterWidth": 14, + "ScrollBgColor": "#6b778d", + "ScrollFgColor": "#17223b", + "TagBgColor": "#263859", + "TagFgColor": "#fefefe", + "WinBorderColor": "#000000" +}