xdg: add option 'xdg.stateHome' (#2439)
It corresponds to the newly introduced `XDG_STATE_HOME`.
This commit is contained in:
parent
288faaa5a6
commit
70c5b268e1
|
@ -23,6 +23,9 @@ runCommand "home-manager-install" {
|
|||
if [[ -v XDG_DATA_HOME && $XDG_DATA_HOME != "$HOME/.local/share" ]]; then
|
||||
xdgVars="$xdgVars xdg.dataHome = \"$XDG_DATA_HOME\";$nl"
|
||||
fi
|
||||
if [[ -v XDG_STATE_HOME && $XDG_STATE_HOME != "$HOME/.local/state" ]]; then
|
||||
xdgVars="$xdgVars xdg.stateHome = \"$XDG_STATE_HOME\";$nl"
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "$confFile")"
|
||||
cat > $confFile <<EOF
|
||||
|
|
|
@ -14,6 +14,7 @@ let
|
|||
defaultCacheHome = "${config.home.homeDirectory}/.cache";
|
||||
defaultConfigHome = "${config.home.homeDirectory}/.config";
|
||||
defaultDataHome = "${config.home.homeDirectory}/.local/share";
|
||||
defaultStateHome = "${config.home.homeDirectory}/.local/state";
|
||||
|
||||
getEnvFallback = name: fallback:
|
||||
let value = builtins.getEnv name;
|
||||
|
@ -67,6 +68,15 @@ in {
|
|||
Absolute path to directory holding application data.
|
||||
'';
|
||||
};
|
||||
|
||||
stateHome = mkOption {
|
||||
type = types.path;
|
||||
defaultText = "~/.local/state";
|
||||
apply = toString;
|
||||
description = ''
|
||||
Absolute path to directory holding application states.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
|
@ -74,11 +84,13 @@ in {
|
|||
xdg.cacheHome = mkDefault defaultCacheHome;
|
||||
xdg.configHome = mkDefault defaultConfigHome;
|
||||
xdg.dataHome = mkDefault defaultDataHome;
|
||||
xdg.stateHome = mkDefault defaultStateHome;
|
||||
|
||||
home.sessionVariables = {
|
||||
XDG_CACHE_HOME = cfg.cacheHome;
|
||||
XDG_CONFIG_HOME = cfg.configHome;
|
||||
XDG_DATA_HOME = cfg.dataHome;
|
||||
XDG_STATE_HOME = cfg.stateHome;
|
||||
};
|
||||
})
|
||||
|
||||
|
@ -96,6 +108,7 @@ in {
|
|||
xdg.cacheHome = mkDefault defaultCacheHome;
|
||||
xdg.configHome = mkDefault defaultConfigHome;
|
||||
xdg.dataHome = mkDefault defaultDataHome;
|
||||
xdg.stateHome = mkDefault stateHome;
|
||||
})
|
||||
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ let
|
|||
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
||||
export XDG_CONFIG_HOME="/home/hm-user/.config"
|
||||
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
||||
export XDG_STATE_HOME="/home/hm-user/.local/state"
|
||||
'';
|
||||
|
||||
darwinExpected = ''
|
||||
|
@ -27,6 +28,7 @@ let
|
|||
export XDG_CACHE_HOME="/home/hm-user/.cache"
|
||||
export XDG_CONFIG_HOME="/home/hm-user/.config"
|
||||
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
||||
export XDG_STATE_HOME="/home/hm-user/.local/state"
|
||||
'';
|
||||
|
||||
expected = pkgs.writeText "expected" (if isDarwin then darwinExpected else linuxExpected);
|
||||
|
|
|
@ -7,15 +7,18 @@ with lib;
|
|||
xdg.configHome = /. + "${config.home.homeDirectory}/.dummy-config";
|
||||
xdg.dataHome = /. + "${config.home.homeDirectory}/.dummy-data";
|
||||
xdg.cacheHome = /. + "${config.home.homeDirectory}/.dummy-cache";
|
||||
xdg.stateHome = /. + "${config.home.homeDirectory}/.dummy-state";
|
||||
|
||||
xdg.configFile.test.text = "config";
|
||||
xdg.dataFile.test.text = "data";
|
||||
home.file."${config.xdg.cacheHome}/test".text = "cache";
|
||||
home.file."${config.xdg.stateHome}/test".text = "state";
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.dummy-config/test
|
||||
assertFileExists home-files/.dummy-cache/test
|
||||
assertFileExists home-files/.dummy-data/test
|
||||
assertFileExists home-files/.dummy-state/test
|
||||
assertFileContent \
|
||||
home-files/.dummy-config/test \
|
||||
${builtins.toFile "test" "config"}
|
||||
|
@ -25,6 +28,9 @@ with lib;
|
|||
assertFileContent \
|
||||
home-files/.dummy-cache/test \
|
||||
${builtins.toFile "test" "cache"}
|
||||
assertFileContent \
|
||||
home-files/.dummy-state/test \
|
||||
${builtins.toFile "test" "state"}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue