diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ef8717a74..417e7e8ca 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -123,6 +123,9 @@ Makefile @thiagokokada /modules/programs/htop.nix @bjpbakker /tests/modules/htop @bjpbakker +/modules/programs/hyfetch.nix @lilyinstarlight +/tests/modules/programs/hyfetch @lilyinstarlight + /modules/programs/i3status.nix @JustinLovinger /modules/programs/i3status-rust.nix @workflow diff --git a/modules/misc/news.nix b/modules/misc/news.nix index fadecda83..fb2c97e03 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -632,6 +632,13 @@ in A new module is available: 'services.recoll'. ''; } + + { + time = "2022-08-01T16:35:28+00:00"; + message = '' + A new module is available: 'programs.hyfetch'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d9e90f7f2..d33f90a3f 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -82,6 +82,7 @@ let ./programs/himalaya.nix ./programs/home-manager.nix ./programs/htop.nix + ./programs/hyfetch.nix ./programs/i3status-rust.nix ./programs/i3status.nix ./programs/info.nix diff --git a/modules/programs/hyfetch.nix b/modules/programs/hyfetch.nix new file mode 100644 index 000000000..b473fd654 --- /dev/null +++ b/modules/programs/hyfetch.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.hyfetch; + + jsonFormat = pkgs.formats.json { }; +in { + meta.maintainers = [ maintainers.lilyinstarlight ]; + + options.programs.hyfetch = { + enable = mkEnableOption "hyfetch"; + + package = mkOption { + type = types.package; + default = pkgs.hyfetch; + defaultText = literalExpression "pkgs.hyfetch"; + description = "The hyfetch package to use."; + }; + + settings = mkOption { + type = jsonFormat.type; + default = { }; + example = literalExpression '' + { + preset = "rainbow"; + mode = "rgb"; + color_align = { + mode = "horizontal"; + }; + } + ''; + description = "JSON config for HyFetch"; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + xdg.configFile."hyfetch.json".source = + jsonFormat.generate "hyfetch.json" cfg.settings; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 4ab7ef9e3..d004c0331 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -74,6 +74,7 @@ import nmt { ./modules/programs/helix ./modules/programs/himalaya ./modules/programs/htop + ./modules/programs/hyfetch ./modules/programs/i3status ./modules/programs/irssi ./modules/programs/kakoune diff --git a/tests/modules/programs/hyfetch/default.nix b/tests/modules/programs/hyfetch/default.nix new file mode 100644 index 000000000..6a5818f91 --- /dev/null +++ b/tests/modules/programs/hyfetch/default.nix @@ -0,0 +1 @@ +{ hyfetch-settings = ./settings.nix; } diff --git a/tests/modules/programs/hyfetch/hyfetch.json b/tests/modules/programs/hyfetch/hyfetch.json new file mode 100644 index 000000000..f94a9757a --- /dev/null +++ b/tests/modules/programs/hyfetch/hyfetch.json @@ -0,0 +1,11 @@ +{ + "color_align": { + "custom_colors": [], + "fore_back": null, + "mode": "horizontal" + }, + "light_dark": "dark", + "lightness": 0.5, + "mode": "rgb", + "preset": "rainbow" +} diff --git a/tests/modules/programs/hyfetch/settings.nix b/tests/modules/programs/hyfetch/settings.nix new file mode 100644 index 000000000..1cd98dc26 --- /dev/null +++ b/tests/modules/programs/hyfetch/settings.nix @@ -0,0 +1,25 @@ +{ ... }: + +{ + programs.hyfetch = { + enable = true; + + settings = { + preset = "rainbow"; + mode = "rgb"; + light_dark = "dark"; + lightness = 0.5; + color_align = { + mode = "horizontal"; + custom_colors = [ ]; + fore_back = null; + }; + }; + }; + + test.stubs.hyfetch = { }; + + nmt.script = '' + assertFileContent home-files/.config/hyfetch.json ${./hyfetch.json} + ''; +}