mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
lsd: allow user to configure colors
Signed-off-by: Avimitin <dev@avimit.in>
This commit is contained in:
parent
2d27bdcd64
commit
835465e8ba
6 changed files with 95 additions and 0 deletions
|
@ -45,6 +45,26 @@ in {
|
||||||
for supported values.
|
for supported values.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
colors = mkOption {
|
||||||
|
type = yamlFormat.type;
|
||||||
|
default = { };
|
||||||
|
example = {
|
||||||
|
size = {
|
||||||
|
none = "grey";
|
||||||
|
small = "yellow";
|
||||||
|
large = "dark_yellow";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Configuration written to {file}`$XDG_CONFIG_HOME/lsd/colors.yaml`. See
|
||||||
|
<https://github.com/lsd-rs/lsd/tree/v1.0.0#color-theme-file-content> for
|
||||||
|
supported colors.
|
||||||
|
|
||||||
|
If this option is non-empty then the `color.theme` option is
|
||||||
|
automatically set to `"custom"`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -56,6 +76,13 @@ in {
|
||||||
|
|
||||||
programs.fish.shellAliases = mkIf cfg.enableAliases aliases;
|
programs.fish.shellAliases = mkIf cfg.enableAliases aliases;
|
||||||
|
|
||||||
|
programs.lsd =
|
||||||
|
mkIf (cfg.colors != { }) { settings.color.theme = "custom"; };
|
||||||
|
|
||||||
|
xdg.configFile."lsd/colors.yaml" = mkIf (cfg.colors != { }) {
|
||||||
|
source = yamlFormat.generate "lsd-colors" cfg.colors;
|
||||||
|
};
|
||||||
|
|
||||||
xdg.configFile."lsd/config.yaml" = mkIf (cfg.settings != { }) {
|
xdg.configFile."lsd/config.yaml" = mkIf (cfg.settings != { }) {
|
||||||
source = yamlFormat.generate "lsd-config" cfg.settings;
|
source = yamlFormat.generate "lsd-config" cfg.settings;
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,6 +96,7 @@ import nmt {
|
||||||
./modules/programs/ledger
|
./modules/programs/ledger
|
||||||
./modules/programs/less
|
./modules/programs/less
|
||||||
./modules/programs/lf
|
./modules/programs/lf
|
||||||
|
./modules/programs/lsd
|
||||||
./modules/programs/lieer
|
./modules/programs/lieer
|
||||||
./modules/programs/man
|
./modules/programs/man
|
||||||
./modules/programs/mbsync
|
./modules/programs/mbsync
|
||||||
|
|
1
tests/modules/programs/lsd/default.nix
Normal file
1
tests/modules/programs/lsd/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ lsd-example-settings = ./example-settings.nix; }
|
8
tests/modules/programs/lsd/example-colors-expected.yaml
Normal file
8
tests/modules/programs/lsd/example-colors-expected.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
date:
|
||||||
|
day-old: green
|
||||||
|
older: dark_green
|
||||||
|
size:
|
||||||
|
large: dark_yellow
|
||||||
|
medium: yellow
|
||||||
|
none: grey
|
||||||
|
small: grey
|
14
tests/modules/programs/lsd/example-settings-expected.yaml
Normal file
14
tests/modules/programs/lsd/example-settings-expected.yaml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
blocks:
|
||||||
|
- date
|
||||||
|
- size
|
||||||
|
- name
|
||||||
|
color:
|
||||||
|
theme: custom
|
||||||
|
date: relative
|
||||||
|
ignore-globs:
|
||||||
|
- .git
|
||||||
|
- .hg
|
||||||
|
- .bsp
|
||||||
|
layout: oneline
|
||||||
|
sorting:
|
||||||
|
dir-grouping: first
|
44
tests/modules/programs/lsd/example-settings.nix
Normal file
44
tests/modules/programs/lsd/example-settings.nix
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.lsd = {
|
||||||
|
enable = true;
|
||||||
|
enableAliases = false;
|
||||||
|
settings = {
|
||||||
|
date = "relative";
|
||||||
|
blocks = [ "date" "size" "name" ];
|
||||||
|
layout = "oneline";
|
||||||
|
sorting.dir-grouping = "first";
|
||||||
|
ignore-globs = [ ".git" ".hg" ".bsp" ];
|
||||||
|
};
|
||||||
|
colors = {
|
||||||
|
date = {
|
||||||
|
day-old = "green";
|
||||||
|
older = "dark_green";
|
||||||
|
};
|
||||||
|
size = {
|
||||||
|
none = "grey";
|
||||||
|
small = "grey";
|
||||||
|
medium = "yellow";
|
||||||
|
large = "dark_yellow";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test.stubs.lsd = { };
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/lsd/config.yaml
|
||||||
|
assertFileExists home-files/.config/lsd/colors.yaml
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/lsd/config.yaml \
|
||||||
|
${./example-settings-expected.yaml}
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/lsd/colors.yaml \
|
||||||
|
${./example-colors-expected.yaml}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue