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:
parent
c3abf8ea1a
commit
17a1004948
3 changed files with 47 additions and 5 deletions
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
37
tests/modules/programs/lsd/example-settings-using-paths.nix
Normal file
37
tests/modules/programs/lsd/example-settings-using-paths.nix
Normal 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}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue