[Desktop/Gaming] make shader cache path relative to $XDG_CACHE_HOME

This commit is contained in:
Antoine Viallon 2023-09-21 14:26:29 +02:00
parent 4c71747514
commit adab1f4179
Signed by: aviallon
GPG key ID: 186FC35EDEB25716
2 changed files with 11 additions and 13 deletions

View file

@ -89,10 +89,14 @@ in {
"__GL_SHADER_DISK_CACHE" = "true";
"__GL_SHADER_DISK_CACHE_SIZE" = "${toString (50 * 1000)}";
"__GL_SHADER_DISK_CACHE_SKIP_CLEANUP" = "1"; # Avoid 128mb limit of shader cache
"__GL_SHADER_DISK_CACHE_PATH" = cfg.graphics.shaderCache.path + "/nvidia" ;
"MESA_SHADER_CACHE_MAX_SIZE" = "50G"; # Put large-enough value. Default is only 1G
"MESA_SHADER_CACHE_DIR" = cfg.graphics.shaderCache.path + "/mesa";
"MESA_GLSL_CACHE_DIR" = cfg.graphics.shaderCache.path + "/mesa";
};
environment.sessionVariables = rec {
XDG_CACHE_HOME = "$HOME/.cache";
"__GL_SHADER_DISK_CACHE_PATH" = "${XDG_CACHE_HOME}/nvidia_gl";
MESA_SHADER_CACHE_DIR = "${XDG_CACHE_HOME}/mesa";
MESA_GLSL_CACHE_DIR = "${XDG_CACHE_HOME}/mesa";
};
programs.steam.package = pkgs.steam.override {
@ -105,9 +109,5 @@ in {
"steam" "steam-original" "steam-runtime" "steam-run"
];
systemd.tmpfiles.rules = [
(mkTmpDir (cfg.graphics.shaderCache.path + "/nvidia") cfg.graphics.shaderCache.cleanupInterval)
(mkTmpDir (cfg.graphics.shaderCache.path + "/mesa") cfg.graphics.shaderCache.cleanupInterval)
];
};
}

View file

@ -39,12 +39,6 @@ in {
};
graphics = {
shaderCache = {
path = mkOption {
description = "Where to put shader cache (currently only for NVidia)";
type = types.path;
default = "/var/tmp/shadercache";
example = "/tmp/shadercache";
};
cleanupInterval = mkOption {
description = "Interval for cache cleanup (tmpfiles.d format). Set to '-' to disable.";
type = types.str;
@ -55,6 +49,10 @@ in {
};
};
imports = [
(mkRemovedOptionModule [ "aviallon" "desktop" "graphics" "shaderCache" "path" ] "Now always relative to $XDG_CACHE_HOME" )
];
config = mkIf cfg.enable {
aviallon.network.backend = mkDefault "NetworkManager";