diff --git a/modules/programs/zapzap.nix b/modules/programs/zapzap.nix new file mode 100644 index 000000000..47749a6bb --- /dev/null +++ b/modules/programs/zapzap.nix @@ -0,0 +1,52 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) + mkIf + mkEnableOption + mkPackageOption + mkOption + ; + + iniFormat = pkgs.formats.ini { }; + cfg = config.programs.zapzap; +in +{ + meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ]; + options.programs.zapzap = { + enable = mkEnableOption "zapzap"; + package = mkPackageOption pkgs "zapzap" { nullable = true; }; + settings = mkOption { + inherit (iniFormat) type; + default = { }; + example = { + notification.donation_message = true; + website.open_page = false; + system = { + scale = 150; + theme = "dark"; + wayland = true; + }; + }; + description = '' + Configuration settings for zapzap. All the available options can be found by + changing the settings from the GUI and looking at $XDG_CONFIG_HOME/ZapZap/ZapZap.conf. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "programs.zapzap" pkgs lib.platforms.linux) + ]; + + home.packages = mkIf (cfg.package != null) [ cfg.package ]; + xdg.configFile."ZapZap/ZapZap.conf" = mkIf (cfg.settings != { }) { + source = iniFormat.generate "ZapZap.conf" cfg.settings; + }; + }; +} diff --git a/tests/modules/programs/zapzap/ZapZap.conf b/tests/modules/programs/zapzap/ZapZap.conf new file mode 100644 index 000000000..b8c1bdca0 --- /dev/null +++ b/tests/modules/programs/zapzap/ZapZap.conf @@ -0,0 +1,10 @@ +[notification] +donation_message=true + +[system] +scale=150 +theme=dark +wayland=true + +[website] +open_page=false diff --git a/tests/modules/programs/zapzap/default.nix b/tests/modules/programs/zapzap/default.nix new file mode 100644 index 000000000..bea74ec28 --- /dev/null +++ b/tests/modules/programs/zapzap/default.nix @@ -0,0 +1,5 @@ +{ lib, pkgs, ... }: + +lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + zapzap-settings = ./settings.nix; +} diff --git a/tests/modules/programs/zapzap/settings.nix b/tests/modules/programs/zapzap/settings.nix new file mode 100644 index 000000000..50fd9a5af --- /dev/null +++ b/tests/modules/programs/zapzap/settings.nix @@ -0,0 +1,20 @@ +{ + programs.zapzap = { + enable = true; + settings = { + notification.donation_message = true; + website.open_page = false; + system = { + scale = 150; + theme = "dark"; + wayland = true; + }; + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/ZapZap/ZapZap.conf + assertFileContent home-files/.config/ZapZap/ZapZap.conf \ + ${./ZapZap.conf} + ''; +}