kubecolor: clean up the handling of config path
This commit is contained in:
parent
94597e670f
commit
1dc235b2fb
4 changed files with 15 additions and 29 deletions
|
|
@ -49,20 +49,9 @@ in
|
|||
|
||||
config =
|
||||
let
|
||||
preferXdgDirectories =
|
||||
config.home.preferXdgDirectories && (!pkgs.stdenv.hostPlatform.isDarwin || config.xdg.enable);
|
||||
configDir =
|
||||
if preferXdgDirectories then
|
||||
"${config.xdg.configHome}/kube"
|
||||
else if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"Library/Application Support/kube"
|
||||
else
|
||||
".kube";
|
||||
|
||||
# https://github.com/kubecolor/kubecolor/pull/145
|
||||
configPathSuffix = lib.optionalString (
|
||||
cfg.package.pname == "kubecolor" && lib.versionOlder (lib.getVersion cfg.package) "0.4"
|
||||
) "color.yaml";
|
||||
preferXdgDirectories = config.home.preferXdgDirectories && config.xdg.enable;
|
||||
configFile =
|
||||
if preferXdgDirectories then "${config.xdg.configHome}/kubecolor.yaml" else ".kube/color.yaml";
|
||||
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
|
|
@ -74,9 +63,11 @@ in
|
|||
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
home.sessionVariables.KUBECOLOR_CONFIG = "${configDir}/${configPathSuffix}";
|
||||
home.sessionVariables = lib.mkIf preferXdgDirectories {
|
||||
KUBECOLOR_CONFIG = configFile;
|
||||
};
|
||||
|
||||
home.file."${configDir}/color.yaml" = mkIf (cfg.settings != { }) {
|
||||
home.file.${configFile} = mkIf (cfg.settings != { }) {
|
||||
source = yamlFormat.generate "kubecolor-settings" cfg.settings;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
{ pkgs, config, ... }:
|
||||
{ config, ... }:
|
||||
|
||||
let
|
||||
configDir = if pkgs.stdenv.isDarwin then "Library/Application Support" else ".config";
|
||||
in
|
||||
{
|
||||
programs.kubecolor = {
|
||||
enable = true;
|
||||
|
|
@ -13,6 +10,7 @@ in
|
|||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists 'home-files/${configDir}/kube/color.yaml'
|
||||
assertPathNotExists 'home-files/.kube/color.yaml'
|
||||
assertPathNotExists 'home-files/.config/kubecolor.yaml'
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
{ pkgs, config, ... }:
|
||||
{ config, ... }:
|
||||
|
||||
let
|
||||
configDir = if pkgs.stdenv.isDarwin then "Library/Application Support/kube" else ".kube";
|
||||
in
|
||||
{
|
||||
programs.kubecolor = {
|
||||
enable = true;
|
||||
|
|
@ -20,8 +17,8 @@ in
|
|||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists 'home-files/${configDir}/color.yaml'
|
||||
assertFileContent 'home-files/${configDir}/color.yaml' \
|
||||
assertFileExists 'home-files/.kube/color.yaml'
|
||||
assertFileContent 'home-files/.kube/color.yaml' \
|
||||
${builtins.toFile "expected.yaml" ''
|
||||
kubectl: kubectl
|
||||
objFreshThreshold: 0
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists 'home-files/.config/kube/color.yaml'
|
||||
assertFileContent 'home-files/.config/kube/color.yaml' \
|
||||
assertFileExists 'home-files/.config/kubecolor.yaml'
|
||||
assertFileContent 'home-files/.config/kubecolor.yaml' \
|
||||
${builtins.toFile "expected.yaml" ''
|
||||
kubectl: kubectl
|
||||
objFreshThreshold: 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue