Skip to content

Commit

Permalink
fix: k9s on darwin with xdg disabled
Browse files Browse the repository at this point in the history
k9s expects configuration files on OS X to live in
`~/Library/Application Support/k9s` instead of `~/.config.k9s`. This
commit handles the case where the module is built for a darwin system
with xdg disabled.

See: #310
  • Loading branch information
alejandro-angulo committed Aug 13, 2024
1 parent 66f4ea1 commit e8b306e
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions modules/home-manager/k9s.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
{ config, lib, ... }:
let
{
config,
lib,
pkgs,
...
}: let
inherit (config.catppuccin) sources;
inherit (pkgs.stdenv.hostPlatform) isDarwin;

cfg = config.programs.k9s.catppuccin;
enable = cfg.enable && config.programs.k9s.enable;

themeName = "catppuccin-${cfg.flavor}" + lib.optionalString cfg.transparent "-transparent";
themeFile = "${themeName}.yaml";
themePath = "/skins/${themeFile}";
configDirectory =
if (isDarwin && !config.xdg.enable)
then "/Library/Application Support/k9s"
else "k9s";
themePath = "${configDirectory}/skins/${themeFile}";
theme = sources.k9s + "/dist/${themeFile}";
in
{
options.programs.k9s.catppuccin = lib.ctp.mkCatppuccinOpt { name = "k9s"; } // {
transparent = lib.mkEnableOption "transparent version of flavor";
};
in {
options.programs.k9s.catppuccin =
lib.ctp.mkCatppuccinOpt {name = "k9s";}
// {
transparent = lib.mkEnableOption "transparent version of flavor";
};

config = lib.mkIf enable {
xdg.configFile."k9s${themePath}".source = theme;
xdg.configFile."${themePath}".source = theme;

programs.k9s.settings.k9s.ui.skin = themeName;
};
Expand Down

0 comments on commit e8b306e

Please sign in to comment.