1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-18 06:51:10 +01:00

lsd: refactor module

This commit is contained in:
Austin Horstman 2025-04-27 21:37:41 -05:00
parent cf351071fb
commit 77f849c114

View file

@ -4,21 +4,10 @@
pkgs, pkgs,
... ...
}: }:
let let
cfg = config.programs.lsd; cfg = config.programs.lsd;
yamlFormat = pkgs.formats.yaml { }; yamlFormat = pkgs.formats.yaml { };
aliases = {
ls = "${pkgs.lsd}/bin/lsd";
ll = "${pkgs.lsd}/bin/lsd -l";
la = "${pkgs.lsd}/bin/lsd -A";
lt = "${pkgs.lsd}/bin/lsd --tree";
lla = "${pkgs.lsd}/bin/lsd -lA";
llt = "${pkgs.lsd}/bin/lsd -l --tree";
};
in in
{ {
imports = imports =
@ -110,11 +99,21 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ pkgs.lsd ]; home.packages = [ pkgs.lsd ];
programs.bash.shellAliases = lib.mkIf cfg.enableBashIntegration aliases; programs =
let
aliases = {
ls = "${pkgs.lsd}/bin/lsd";
ll = "${pkgs.lsd}/bin/lsd -l";
la = "${pkgs.lsd}/bin/lsd -A";
lt = "${pkgs.lsd}/bin/lsd --tree";
lla = "${pkgs.lsd}/bin/lsd -lA";
llt = "${pkgs.lsd}/bin/lsd -l --tree";
};
in
{
bash.shellAliases = lib.mkIf cfg.enableBashIntegration aliases;
programs.zsh.shellAliases = lib.mkIf cfg.enableZshIntegration aliases; fish = lib.mkMerge [
programs.fish = lib.mkMerge [
(lib.mkIf (!config.programs.fish.preferAbbrs) { (lib.mkIf (!config.programs.fish.preferAbbrs) {
shellAliases = lib.mkIf cfg.enableFishIntegration aliases; shellAliases = lib.mkIf cfg.enableFishIntegration aliases;
}) })
@ -124,18 +123,23 @@ in
}) })
]; ];
programs.lsd = lib.mkIf (cfg.colors != { }) { settings.color.theme = "custom"; }; lsd = lib.mkIf (cfg.colors != { }) { settings.color.theme = "custom"; };
xdg.configFile."lsd/colors.yaml" = lib.mkIf (cfg.colors != { }) { zsh.shellAliases = lib.mkIf cfg.enableZshIntegration aliases;
};
xdg.configFile = {
"lsd/colors.yaml" = lib.mkIf (cfg.colors != { }) {
source = yamlFormat.generate "lsd-colors" cfg.colors; source = yamlFormat.generate "lsd-colors" cfg.colors;
}; };
xdg.configFile."lsd/icons.yaml" = lib.mkIf (cfg.icons != { }) { "lsd/config.yaml" = lib.mkIf (cfg.settings != { }) {
source = yamlFormat.generate "lsd-icons" cfg.icons; source = yamlFormat.generate "lsd-config" cfg.settings;
}; };
xdg.configFile."lsd/config.yaml" = lib.mkIf (cfg.settings != { }) { "lsd/icons.yaml" = lib.mkIf (cfg.icons != { }) {
source = yamlFormat.generate "lsd-config" cfg.settings; source = yamlFormat.generate "lsd-icons" cfg.icons;
};
}; };
}; };
} }