1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

lsd: allow specifying a path type value for icons and colors options (#7733)

This allows users to use an icons or colors theme file taken from GitHub
directly without the YAML -> Nix translation in the configuration.
This commit is contained in:
Hoang Nguyen 2025-09-14 00:32:33 +00:00 committed by GitHub
parent c3abf8ea1a
commit 17a1004948
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 5 deletions

View file

@ -54,7 +54,7 @@ in
};
colors = lib.mkOption {
type = yamlFormat.type;
type = lib.types.either yamlFormat.type lib.types.path;
default = { };
example = {
size = {
@ -74,7 +74,7 @@ in
};
icons = lib.mkOption {
type = yamlFormat.type;
type = lib.types.either yamlFormat.type lib.types.path;
default = { };
example = {
name = {
@ -132,7 +132,8 @@ in
xdg.configFile = {
"lsd/colors.yaml" = lib.mkIf (cfg.colors != { }) {
source = yamlFormat.generate "lsd-colors" cfg.colors;
source =
if lib.types.path.check cfg.colors then cfg.colors else yamlFormat.generate "lsd-colors" cfg.colors;
};
"lsd/config.yaml" = lib.mkIf (cfg.settings != { }) {
@ -140,7 +141,8 @@ in
};
"lsd/icons.yaml" = lib.mkIf (cfg.icons != { }) {
source = yamlFormat.generate "lsd-icons" cfg.icons;
source =
if lib.types.path.check cfg.icons then cfg.icons else yamlFormat.generate "lsd-icons" cfg.icons;
};
};
};

View file

@ -1 +1,4 @@
{ lsd-example-settings = ./example-settings.nix; }
{
lsd-example-settings = ./example-settings.nix;
lsd-example-settings-using-paths = ./example-settings-using-paths.nix;
}

View file

@ -0,0 +1,37 @@
{
programs.lsd = {
enable = true;
settings = {
date = "relative";
blocks = [
"date"
"size"
"name"
];
layout = "oneline";
sorting.dir-grouping = "first";
ignore-globs = [
".git"
".hg"
".bsp"
];
};
colors = ./example-colors-expected.yaml;
icons = ./example-icons-expected.yaml;
};
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}
'';
}