Add xdg settings, cache, cleanup script

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-06-21 23:39:18 +03:00
parent ce37f320c2
commit 48f391e3ad
22 changed files with 245 additions and 51 deletions

View File

@@ -6,25 +6,20 @@ in {
programs.fuse.userAllowOther = lib.mkIf (users != [ ]) true;
systemd.tmpfiles.rules = lib.mkIf (users != [ ]) (
[ "d /persist/home 0755 root root -" ] ++
lib.attrsets.mapAttrsToList (user: config: "d /persist${config.home} 0700 ${user} users -") users
[
"d /persist/home 0755 root root -"
"d /cache/home 0755 root root -"
] ++
lib.attrsets.mapAttrsToList (user: config: "d /persist${config.home} 0700 ${user} users -") users ++
lib.attrsets.mapAttrsToList (user: config: "d /cache${config.home} 0700 ${user} users -") users
);
home-manager.users = lib.attrsets.mapAttrs (user: config: ({
imports = [ inputs.impermanence.nixosModules.home-manager.impermanence ];
home.persistence."/persist${config.home}" = {
allowOther = true;
directories = [
"Documents"
"Downloads"
"Music"
"Pictures"
"Videos"
"Templates"
"VMs"
"git"
];
home.persistence = {
"/persist${config.home}".allowOther = true;
"/cache${config.home}".allowOther = true;
};
})) users;
}

View File

@@ -0,0 +1,44 @@
{ config, lib, ... }:
let
users = lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users;
in {
home-manager.users = lib.attrsets.mapAttrs (user: cfg: (let
cacheHome = "${cfg.home}/.cache";
configHome = "${cfg.home}/.config";
dataHome = "${cfg.home}/.local/share";
stateHome = "${cfg.home}/.local/state";
xdgVmDir = "${cfg.home}/VMs";
xdgGitDir = "${cfg.home}/git";
in {
xdg = {
enable = true;
mimeApps.enable = true;
inherit cacheHome;
inherit configHome;
inherit dataHome;
inherit stateHome;
userDirs = {
enable = true;
extraConfig = {
XDG_VM_DIR = xdgVmDir;
XDG_GIT_DIR = xdgGitDir;
};
};
};
home.persistence."/persist${cfg.home}".directories = [
"Desktop" # userDirs.desktop
"Documents" # userDirs.documents
"Downloads" # userDirs.download
"Music" # userDirs.music
"Pictures" # userDirs.pictures
"Templates" # userDirs.templates
"Videos" # userDirs.videos
"VMs" # xdgVmDir
"git" # xdgGitDir
];
})) users;
}

View File

@@ -1,4 +1,4 @@
{ inputs, ... }:
{ config, inputs, ... }:
{
imports = [
@@ -6,6 +6,7 @@
./options.nix
./configs/persist
./configs/sops
./configs/xdg
];
home-manager = {
@@ -15,6 +16,7 @@
sharedModules = [{
home.stateVersion = "24.05";
systemd.user.startServices = "sd-switch";
nix.settings = config.nix.settings;
}];
};