diff --git a/modules/programs/lsd.nix b/modules/programs/lsd.nix index 4d875c7f9..741b254c7 100644 --- a/modules/programs/lsd.nix +++ b/modules/programs/lsd.nix @@ -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; }; }; }; diff --git a/tests/modules/programs/lsd/default.nix b/tests/modules/programs/lsd/default.nix index 6a1454c9a..c89c9ad14 100644 --- a/tests/modules/programs/lsd/default.nix +++ b/tests/modules/programs/lsd/default.nix @@ -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; +} diff --git a/tests/modules/programs/lsd/example-settings-using-paths.nix b/tests/modules/programs/lsd/example-settings-using-paths.nix new file mode 100644 index 000000000..c0ca68df4 --- /dev/null +++ b/tests/modules/programs/lsd/example-settings-using-paths.nix @@ -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} + ''; +}