diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 50e538e4..a09f085c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -117,6 +117,9 @@ Makefile @thiagokokada /modules/services/fusuma.nix @iosmanthus /tests/modules/services/fusuma @iosmanthus +/modules/programs/fuzzel.nix @Scrumplex +/tests/modules/programs/fuzzel @Scrumplex + /modules/programs/gallery-dl.nix @marsam /tests/modules/programs/gallery-dl @marsam diff --git a/modules/misc/news.nix b/modules/misc/news.nix index ac7f914b..fa033a51 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1015,6 +1015,14 @@ in A new module is available: 'programs.translate-shell'. ''; } + + { + time = "2023-05-13T13:51:18+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'programs.fuzzel'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index ddc32535..91b8bf0b 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -76,6 +76,7 @@ let ./programs/firefox.nix ./programs/fish.nix ./programs/foot.nix + ./programs/fuzzel.nix ./programs/fzf.nix ./programs/gallery-dl.nix ./programs/getmail.nix diff --git a/modules/programs/fuzzel.nix b/modules/programs/fuzzel.nix new file mode 100644 index 00000000..aff97cf1 --- /dev/null +++ b/modules/programs/fuzzel.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +let + + inherit (lib) literalExpression mkEnableOption mkPackageOption mkOption mkIf; + + cfg = config.programs.fuzzel; + + iniFormat = pkgs.formats.ini { }; + +in { + meta.maintainers = [ lib.maintainers.Scrumplex ]; + + options.programs.fuzzel = { + enable = mkEnableOption "fuzzel"; + + package = mkPackageOption pkgs "fuzzel" { }; + + settings = mkOption { + type = iniFormat.type; + default = { }; + example = literalExpression '' + { + main = { + terminal = "''${pkgs.foot}/bin/foot"; + layer = "overlay"; + }; + colors.background = "ffffffff"; + } + ''; + description = '' + Configuration for fuzzel written to + $XDG_CONFIG_HOME/fuzzel/fuzzel.ini. See + fuzzel.ini + 5 for a list of available options. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "programs.fuzzel" pkgs + lib.platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + xdg.configFile."fuzzel/fuzzel.ini" = mkIf (cfg.settings != { }) { + source = iniFormat.generate "fuzzel.ini" cfg.settings; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 134f2324..d744a5f7 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -157,6 +157,7 @@ import nmt { ./modules/programs/borgmatic ./modules/programs/firefox ./modules/programs/foot + ./modules/programs/fuzzel ./modules/programs/getmail ./modules/programs/gnome-terminal ./modules/programs/hexchat diff --git a/tests/modules/programs/fuzzel/default.nix b/tests/modules/programs/fuzzel/default.nix new file mode 100644 index 00000000..702bd0d6 --- /dev/null +++ b/tests/modules/programs/fuzzel/default.nix @@ -0,0 +1,4 @@ +{ + fuzzel-example-settings = ./example-settings.nix; + fuzzel-empty-settings = ./empty-settings.nix; +} diff --git a/tests/modules/programs/fuzzel/empty-settings.nix b/tests/modules/programs/fuzzel/empty-settings.nix new file mode 100644 index 00000000..e14aad4f --- /dev/null +++ b/tests/modules/programs/fuzzel/empty-settings.nix @@ -0,0 +1,11 @@ +{ ... }: + +{ + programs.fuzzel.enable = true; + + test.stubs.fuzzel = { }; + + nmt.script = '' + assertPathNotExists home-files/.config/fuzzel + ''; +} diff --git a/tests/modules/programs/fuzzel/example-settings-expected.ini b/tests/modules/programs/fuzzel/example-settings-expected.ini new file mode 100644 index 00000000..8e9c8e58 --- /dev/null +++ b/tests/modules/programs/fuzzel/example-settings-expected.ini @@ -0,0 +1,6 @@ +[border] +width=6 + +[main] +dpi-aware=yes +font=Fira Code:size=11 diff --git a/tests/modules/programs/fuzzel/example-settings.nix b/tests/modules/programs/fuzzel/example-settings.nix new file mode 100644 index 00000000..3273af58 --- /dev/null +++ b/tests/modules/programs/fuzzel/example-settings.nix @@ -0,0 +1,23 @@ +{ config, ... }: + +{ + programs.fuzzel = { + enable = true; + package = config.lib.test.mkStubPackage { }; + + settings = { + main = { + font = "Fira Code:size=11"; + dpi-aware = "yes"; + }; + + border = { width = 6; }; + }; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/fuzzel/fuzzel.ini \ + ${./example-settings-expected.ini} + ''; +}