2021-09-15 18:13:47 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-09-15 16:48:39 +02:00
|
|
|
let
|
|
|
|
cfg = config.my.programs.steam;
|
2023-06-03 14:39:52 +02:00
|
|
|
|
|
|
|
steam = pkgs.steam;
|
2021-09-15 16:48:39 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.programs.steam = with lib; {
|
|
|
|
enable = mkEnableOption "steam configuration";
|
2021-09-15 18:13:47 +02:00
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "$XDG_DATA_HOME/steamlib";
|
|
|
|
example = "/mnt/steam/";
|
|
|
|
description = ''
|
|
|
|
Which directory should be used as HOME to run steam.
|
|
|
|
'';
|
|
|
|
};
|
2021-09-15 16:48:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
programs.steam = {
|
|
|
|
enable = true;
|
|
|
|
};
|
2021-09-15 18:13:47 +02:00
|
|
|
|
|
|
|
environment.systemPackages = builtins.map lib.hiPrio [
|
|
|
|
# Respect XDG conventions, leave my HOME alone
|
2023-06-03 14:39:52 +02:00
|
|
|
(pkgs.writeShellScriptBin "steam" ''
|
2021-09-15 18:13:47 +02:00
|
|
|
mkdir -p "${cfg.dataDir}"
|
2023-06-03 14:39:52 +02:00
|
|
|
HOME="${cfg.dataDir}" exec ${lib.getExe steam} "$@"
|
2021-09-15 18:13:47 +02:00
|
|
|
'')
|
|
|
|
# Same, for GOG and other such games
|
2023-06-03 14:39:52 +02:00
|
|
|
(pkgs.writeShellScriptBin "steam-run" ''
|
2021-09-15 18:13:47 +02:00
|
|
|
mkdir -p "${cfg.dataDir}"
|
2023-06-03 14:39:52 +02:00
|
|
|
HOME="${cfg.dataDir}" exec ${lib.getExe steam.run} "$@"
|
2021-09-15 18:13:47 +02:00
|
|
|
'')
|
|
|
|
];
|
2021-09-15 16:48:39 +02:00
|
|
|
};
|
|
|
|
}
|