From 0b8df9eeb66941ef32e5761ecf4cddff91e5c020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Abdelkader=20Mart=C3=ADnez=20P=C3=A9rez?= <robertomartinezp@gmail.com> Date: Tue, 21 Jan 2025 13:12:40 +0100 Subject: [PATCH] lsd: add support for icons.yaml This update introduces support for icons.yaml in the lsd module, enhancing the customization options for file icons. Co-authored-by: pancho horrillo <pancho@pancho.name> --- modules/programs/lsd.nix | 28 +++++++++++++++++++ .../programs/lsd/example-icons-expected.yaml | 9 ++++++ .../modules/programs/lsd/example-settings.nix | 18 ++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tests/modules/programs/lsd/example-icons-expected.yaml diff --git a/modules/programs/lsd.nix b/modules/programs/lsd.nix index 0053a494f..beefef8c2 100644 --- a/modules/programs/lsd.nix +++ b/modules/programs/lsd.nix @@ -65,6 +65,30 @@ in { automatically set to `"custom"`. ''; }; + + icons = mkOption { + type = yamlFormat.type; + default = { }; + example = { + name = { + ".trash" = ""; + ".cargo" = ""; + }; + extension = { + "go" = ""; + "hs" = ""; + }; + filetype = { + "dir" = "📂"; + "file" = "📄"; + }; + }; + description = '' + Configuration written to {file}`$XDG_CONFIG_HOME/lsd/icons.yaml`. See + <https://github.com/lsd-rs/lsd?tab=readme-ov-file#icon-theme-file-content> for + details. + ''; + }; }; config = mkIf cfg.enable { @@ -91,6 +115,10 @@ in { source = yamlFormat.generate "lsd-colors" cfg.colors; }; + xdg.configFile."lsd/icons.yaml" = mkIf (cfg.icons != { }) { + source = yamlFormat.generate "lsd-icons" cfg.icons; + }; + xdg.configFile."lsd/config.yaml" = mkIf (cfg.settings != { }) { source = yamlFormat.generate "lsd-config" cfg.settings; }; diff --git a/tests/modules/programs/lsd/example-icons-expected.yaml b/tests/modules/programs/lsd/example-icons-expected.yaml new file mode 100644 index 000000000..a640b3bc7 --- /dev/null +++ b/tests/modules/programs/lsd/example-icons-expected.yaml @@ -0,0 +1,9 @@ +extension: + go: + hs: +filetype: + dir: 📂 + file: 📄 +name: + .cargo: + .trash: diff --git a/tests/modules/programs/lsd/example-settings.nix b/tests/modules/programs/lsd/example-settings.nix index f9217a098..01c143a60 100644 --- a/tests/modules/programs/lsd/example-settings.nix +++ b/tests/modules/programs/lsd/example-settings.nix @@ -26,6 +26,20 @@ with lib; large = "dark_yellow"; }; }; + icons = { + name = { + ".trash" = ""; + ".cargo" = ""; + }; + extension = { + "go" = ""; + "hs" = ""; + }; + filetype = { + "dir" = "📂"; + "file" = "📄"; + }; + }; }; test.stubs.lsd = { }; @@ -33,12 +47,16 @@ with lib; nmt.script = '' assertFileExists home-files/.config/lsd/config.yaml assertFileExists home-files/.config/lsd/colors.yaml + assertFileExists home-files/.config/lsd/icons.yaml assertFileContent \ home-files/.config/lsd/config.yaml \ ${./example-settings-expected.yaml} assertFileContent \ home-files/.config/lsd/colors.yaml \ ${./example-colors-expected.yaml} + assertFileContent \ + home-files/.config/lsd/icons.yaml \ + ${./example-icons-expected.yaml} ''; }; }