Add steam games directory sync

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-08-30 12:06:48 +03:00
parent 92b61345d5
commit eaeb6aa4c6
2 changed files with 106 additions and 1 deletions

View File

@@ -2,7 +2,12 @@
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
environment.persistence."/persist" = {
"${home}/.steam" = { };
@@ -29,6 +34,49 @@
};
home-manager.users.${user} = {
systemd.user = {
tmpfiles.rules = [ "d ${home}/.local/share/Steam/steamapps/common 0755 ${user} users -" ];
services.steam-ln =
let
steamLn = lib.meta.getExe (
pkgs.writeShellApplication {
name = "steam-ln";
runtimeInputs = with pkgs; [ coreutils ];
text = builtins.readFile ./scripts/steam-ln.sh;
}
);
in
{
Unit = {
Description = "Sync Steam games with Games directory";
After = [
config.environment.persistence."/persist"."${home}/.local/share/Steam".mount
config.environment.persistence."/persist"."${home}/Games".mount
];
DefaultDependencies = false;
};
Service = {
ExecStart = steamLn;
Type = "oneshot";
};
};
paths.steam-ln = {
Unit = {
Description = "Monitor Steam games directory for changes";
After = [
config.environment.persistence."/persist"."${home}/.local/share/Steam".mount
config.environment.persistence."/persist"."${home}/Games".mount
];
};
Path.PathChanged = "${home}/.local/share/Steam/steamapps/common";
Install.WantedBy = [ "graphical-session.target" ];
};
};
home = {
packages = with pkgs; [ protonup ];
sessionVariables.STEAM_EXTRA_COMPAT_TOOLS_PATHS = "${home}/.steam/root/compatibilitytools.d";