diff --git a/modules/programs/amfora.nix b/modules/programs/amfora.nix new file mode 100644 index 000000000..78fe1765c --- /dev/null +++ b/modules/programs/amfora.nix @@ -0,0 +1,80 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + types + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + cfg = config.programs.amfora; + tomlFormat = pkgs.formats.toml { }; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + options.programs.amfora = { + enable = mkEnableOption "amfora"; + package = mkPackageOption pkgs "amfora" { nullable = true; }; + settings = mkOption { + inherit (tomlFormat) type; + default = { }; + example = { + a-general = { + home = "gemini://geminiprotocol.net"; + auto_redirect = false; + http = "default"; + search = "gemini://geminispace.info/search"; + color = true; + ansi = true; + highlight_code = true; + highlight_style = "monokai"; + bullets = true; + }; + }; + description = '' + Configuration settings for amfora. All available options can be found here: + . + ''; + }; + bookmarks = mkOption { + type = with types; either str path; + default = ""; + example = '' + + + + + Example Bookmark + + + ''; + description = '' + Bookmarks file for amfora. It's highly recommended that you edit + this file through the program itself, and then look at + $XDG_DATA_HOME/amfora/bookmarks.xml + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."amfora/config.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "amfora-config.toml" cfg.settings; + }; + xdg.dataFile."amfora/bookmarks.xml" = mkIf (cfg.bookmarks != "") { + source = + if lib.isPath cfg.bookmarks then + cfg.bookmarks + else + pkgs.writeText "amfora-bookmarks.xml" cfg.bookmarks; + }; + }; +} diff --git a/tests/modules/programs/amfora/bookmarks.xml b/tests/modules/programs/amfora/bookmarks.xml new file mode 100644 index 000000000..6506929f4 --- /dev/null +++ b/tests/modules/programs/amfora/bookmarks.xml @@ -0,0 +1,9 @@ + + + + + Example Bookmark + + diff --git a/tests/modules/programs/amfora/config.toml b/tests/modules/programs/amfora/config.toml new file mode 100644 index 000000000..a0c8767cb --- /dev/null +++ b/tests/modules/programs/amfora/config.toml @@ -0,0 +1,10 @@ +[a-general] +ansi = true +auto_redirect = false +bullets = true +color = true +highlight_code = true +highlight_style = "monokai" +home = "gemini://geminiprotocol.net" +http = "default" +search = "gemini://geminispace.info/search" diff --git a/tests/modules/programs/amfora/default.nix b/tests/modules/programs/amfora/default.nix new file mode 100644 index 000000000..0b1d9bfb6 --- /dev/null +++ b/tests/modules/programs/amfora/default.nix @@ -0,0 +1 @@ +{ amfora-settings = ./settings.nix; } diff --git a/tests/modules/programs/amfora/settings.nix b/tests/modules/programs/amfora/settings.nix new file mode 100644 index 000000000..d453d223c --- /dev/null +++ b/tests/modules/programs/amfora/settings.nix @@ -0,0 +1,40 @@ +{ + programs.amfora = { + enable = true; + settings = { + a-general = { + home = "gemini://geminiprotocol.net"; + auto_redirect = false; + http = "default"; + search = "gemini://geminispace.info/search"; + color = true; + ansi = true; + highlight_code = true; + highlight_style = "monokai"; + bullets = true; + }; + }; + + bookmarks = '' + + + + + Example Bookmark + + + ''; + }; + + nmt.script = '' + assertFileExists home-files/.config/amfora/config.toml + assertFileContent home-files/.config/amfora/config.toml \ + ${./config.toml} + + assertFileExists home-files/.local/share/amfora/bookmarks.xml + assertFileContent home-files/.local/share/amfora/bookmarks.xml \ + ${./bookmarks.xml} + ''; +}