Add xdg settings, cache, cleanup script
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,6 +1,22 @@
|
||||
{ user ? throw "user argument is required" }: { pkgs, ... }:
|
||||
{ user ? throw "user argument is required" }: { inputs, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
let
|
||||
configDir = ".config/Code";
|
||||
cacheDirs = [
|
||||
".config/Code/Cache"
|
||||
".config/Code/CachedConfigurations"
|
||||
".config/Code/CachedData"
|
||||
".config/Code/CachedExtensionVSIXs"
|
||||
".config/Code/CachedExtensions"
|
||||
".config/Code/CachedProfilesData"
|
||||
".config/Code/Code Cache"
|
||||
".config/Code/DawnCache"
|
||||
".config/Code/GPUCache"
|
||||
".config/Code/Service Worker/CacheStorage"
|
||||
".config/Code/Service Worker/ScriptCache"
|
||||
];
|
||||
inherit (pkgs.callPackage "${inputs.impermanence}/lib.nix" { }) sanitizeName concatPaths;
|
||||
in {
|
||||
home-manager.users."${user.name}" = {
|
||||
programs.vscode = {
|
||||
enable = true;
|
||||
@@ -59,6 +75,28 @@
|
||||
./langs/nix.nix
|
||||
];
|
||||
|
||||
home.persistence."/persist${user.home}".directories = [ ".config/Code" ];
|
||||
home.persistence = {
|
||||
"/persist${user.home}".directories = [ configDir ];
|
||||
# Bastard: https://github.com/microsoft/vscode/issues/3884
|
||||
"/cache${user.home}".directories = cacheDirs;
|
||||
};
|
||||
|
||||
# Some filthy fucking shit below, be warned.
|
||||
# Microsoft stores cache under .config/Code instead of .cache/Code like normal people.
|
||||
# Sometimes a race condition is caused if the cache bind mounts are created before the config one.
|
||||
# So we do this. Sorry.
|
||||
# https://github.com/nix-community/impermanence/blob/27979f1c3a0d3b9617a3563e2839114ba7d48d3f/home-manager.nix#L238
|
||||
systemd.user.services = let
|
||||
configDirService = "bindMount-${sanitizeName (lib.strings.escapeShellArg (concatPaths [ "/persist${user.home}" configDir ]))}.service";
|
||||
in
|
||||
builtins.listToAttrs (builtins.map (dir: {
|
||||
name = "bindMount-${sanitizeName (lib.strings.escapeShellArg (concatPaths [ "/cache${user.home}" dir ]))}";
|
||||
value = {
|
||||
Unit = {
|
||||
Requires = [ configDirService ];
|
||||
After = [ configDirService ];
|
||||
};
|
||||
};
|
||||
}) cacheDirs);
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user