mirror of
https://github.com/js0ny/dotfiles.git
synced 2026-02-04 03:20:32 +00:00
nix: gaming packages
This commit is contained in:
parent
18bdb02ca1
commit
d0b6200eae
3 changed files with 166 additions and 33 deletions
|
|
@ -4,45 +4,54 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
# Helper to handle the logic check string
|
||||||
|
# 如果 force 为 true,Bash 变量 FORCE 为 "true",否则为 "false"
|
||||||
|
# In Nix, (toString true) yields "1"
|
||||||
|
mkForceVar = force:
|
||||||
|
if force
|
||||||
|
then "true"
|
||||||
|
else "false";
|
||||||
|
|
||||||
mkMergedYaml = {
|
mkMergedYaml = {
|
||||||
name, # This value should be unique for each merged YAML config
|
name,
|
||||||
target, # The target YAML file path relative to $HOME
|
target,
|
||||||
settings, # The Nix Settings to convert to YAML and merge
|
settings,
|
||||||
|
force ? false,
|
||||||
}: let
|
}: let
|
||||||
yamlContent = lib.generators.toYAML {} settings;
|
yamlContent = lib.generators.toYAML {} settings;
|
||||||
|
|
||||||
# This file will hold the Nix-managed YAML content
|
|
||||||
# symlink to /nix/store/***.nix-managed for clarity
|
|
||||||
patchFile = "${target}.nix-managed";
|
patchFile = "${target}.nix-managed";
|
||||||
in {
|
in {
|
||||||
# Write the Nix-managed YAML content for merging and preservation
|
|
||||||
home.file."${patchFile}".text = yamlContent;
|
home.file."${patchFile}".text = yamlContent;
|
||||||
|
|
||||||
home.activation."merge-${name}" = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
home.activation."merge-${name}" = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||||
TARGET="$HOME/${target}"
|
TARGET="$HOME/${target}"
|
||||||
PATCH="$HOME/${patchFile}"
|
PATCH="$HOME/${patchFile}"
|
||||||
|
FORCE="${mkForceVar force}"
|
||||||
|
|
||||||
if [ -f "$PATCH" ]; then
|
if [ -f "$TARGET" ] || [ "$FORCE" = "true" ]; then
|
||||||
verboseEcho "Merging Nix managed YAML config into: $TARGET"
|
if [ -f "$PATCH" ]; then
|
||||||
|
verboseEcho "Merging Nix managed YAML config into: $TARGET"
|
||||||
|
|
||||||
run mkdir -p "$(dirname "$TARGET")"
|
# 只有在确定要操作时,才创建目录和空文件
|
||||||
|
run mkdir -p "$(dirname "$TARGET")"
|
||||||
|
|
||||||
if [ ! -f "$TARGET" ]; then
|
if [ ! -f "$TARGET" ]; then
|
||||||
echo "{}" > "$TARGET"
|
echo "{}" > "$TARGET"
|
||||||
|
fi
|
||||||
|
|
||||||
|
run ${pkgs.yq-go}/bin/yq -i -oy -P ". *= load(\"$PATCH\")" "$TARGET"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
# Arguments:
|
verboseEcho "Skipping merge for $TARGET: file missing and force=false"
|
||||||
# * -i: In-place edit
|
|
||||||
# * -oy: Output YAML
|
|
||||||
# * -P: Pretty Print (indentation, etc.)
|
|
||||||
run ${pkgs.yq-go}/bin/yq -i -oy -P ". *= load(\"$PATCH\")" "$TARGET"
|
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
mkMergedJson = {
|
mkMergedJson = {
|
||||||
name,
|
name,
|
||||||
target,
|
target,
|
||||||
settings,
|
settings,
|
||||||
|
force ? false,
|
||||||
}: let
|
}: let
|
||||||
jsonContent = builtins.toJSON settings;
|
jsonContent = builtins.toJSON settings;
|
||||||
patchFile = "${target}.nix-managed";
|
patchFile = "${target}.nix-managed";
|
||||||
|
|
@ -52,24 +61,31 @@
|
||||||
home.activation."merge-${name}" = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
home.activation."merge-${name}" = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||||
TARGET="$HOME/${target}"
|
TARGET="$HOME/${target}"
|
||||||
PATCH="$HOME/${patchFile}"
|
PATCH="$HOME/${patchFile}"
|
||||||
|
FORCE="${mkForceVar force}"
|
||||||
|
|
||||||
if [ -f "$PATCH" ]; then
|
if [ -f "$TARGET" ] || [ "$FORCE" = "true" ]; then
|
||||||
verboseEcho "Merging Nix managed JSON config into: $TARGET"
|
if [ -f "$PATCH" ]; then
|
||||||
|
verboseEcho "Merging Nix managed JSON config into: $TARGET"
|
||||||
|
|
||||||
run mkdir -p "$(dirname "$TARGET")"
|
run mkdir -p "$(dirname "$TARGET")"
|
||||||
|
|
||||||
if [ ! -f "$TARGET" ]; then
|
if [ ! -f "$TARGET" ]; then
|
||||||
echo "{}" > "$TARGET"
|
echo "{}" > "$TARGET"
|
||||||
|
fi
|
||||||
|
|
||||||
|
run ${pkgs.yq-go}/bin/yq -i -o json -P --indent 2 ". *= load(\"$PATCH\")" "$TARGET"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
run ${pkgs.yq-go}/bin/yq -i -o json -P --indent 2 ". *= load(\"$PATCH\")" "$TARGET"
|
verboseEcho "Skipping merge for $TARGET: file missing and force=false"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
mkMergedIni = {
|
mkMergedIni = {
|
||||||
name,
|
name,
|
||||||
target,
|
target,
|
||||||
settings,
|
settings,
|
||||||
|
force ? false,
|
||||||
}: let
|
}: let
|
||||||
iniContent = lib.generators.toINI {} settings;
|
iniContent = lib.generators.toINI {} settings;
|
||||||
patchFile = "${target}.nix-managed";
|
patchFile = "${target}.nix-managed";
|
||||||
|
|
@ -79,16 +95,22 @@
|
||||||
home.activation."merge-${name}" = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
home.activation."merge-${name}" = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||||
TARGET="$HOME/${target}"
|
TARGET="$HOME/${target}"
|
||||||
PATCH="$HOME/${patchFile}"
|
PATCH="$HOME/${patchFile}"
|
||||||
if [ -f "$PATCH" ]; then
|
FORCE="${mkForceVar force}"
|
||||||
verboseEcho "Merging Nix managed INI config into: $TARGET"
|
|
||||||
|
|
||||||
run mkdir -p "$(dirname "$TARGET")"
|
if [ -f "$TARGET" ] || [ "$FORCE" = "true" ]; then
|
||||||
|
if [ -f "$PATCH" ]; then
|
||||||
|
verboseEcho "Merging Nix managed INI config into: $TARGET"
|
||||||
|
|
||||||
if [ ! -f "$TARGET" ]; then
|
run mkdir -p "$(dirname "$TARGET")"
|
||||||
echo "" > "$TARGET"
|
|
||||||
|
if [ ! -f "$TARGET" ]; then
|
||||||
|
echo "" > "$TARGET"
|
||||||
|
fi
|
||||||
|
|
||||||
|
run ${pkgs.crudini}/bin/crudini --merge "$TARGET" < "$PATCH"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
run ${pkgs.crudini}/bin/crudini --merge "$TARGET" < "$PATCH"
|
verboseEcho "Skipping merge for $TARGET: file missing and force=false"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,99 @@
|
||||||
{pkgs, ...}: {
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
mergetools = import ../lib/mergetools.nix {inherit pkgs lib config;};
|
||||||
|
mkMergedJson = mergetools.mkMergedJson;
|
||||||
|
mkMergedIni = mergetools.mkMergedIni;
|
||||||
|
pdxrel = ".local/share/Paradox Interactive";
|
||||||
|
# pdxbase = "${config.home.homeDirectory}/${pdxrel}";
|
||||||
|
euvbase = "${config.home.homeDirectory}/.local/share/Steam/steamapps/compatdata/3450310/pfx/drive_c/users/steamuser/Documents/Paradox Interactive/Europa Universalis V";
|
||||||
|
paradoxLauncherUserSettings = mkMergedJson {
|
||||||
|
name = "paradox-launcher-usersettings";
|
||||||
|
target = "${pdxrel}/launcher-v2/userSettings.json";
|
||||||
|
settings = {
|
||||||
|
"optionalTelemetryDisabled" = true;
|
||||||
|
"language" = "zh-hans";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
pdxSdkSettingsEU5 = mkMergedJson {
|
||||||
|
name = "pdxSdkaccountJsonEU5";
|
||||||
|
target = "${euvbase}/PDX/SDK/eu5/account.json";
|
||||||
|
settings = {
|
||||||
|
telemetryEnabled = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
# 经典 $HOME 下拉屎
|
||||||
|
pdxSdkSettingsV3 = mkMergedJson {
|
||||||
|
name = "pdxSdkaccountJsonV3";
|
||||||
|
target = "PDX/SDK/victoria3/account.json";
|
||||||
|
settings = {
|
||||||
|
telemetryEnabled = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
pdxSdkTelemetryEU5 = mkMergedJson {
|
||||||
|
name = "pdxSdktelemetryConsentEU5";
|
||||||
|
target = "${euvbase}/PDX/SDK/eu5/telemetry_consent.json";
|
||||||
|
settings = {
|
||||||
|
telemetry_consent_choice = "denied";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
pdxSdkTelemetryV3 = mkMergedJson {
|
||||||
|
name = "pdxSdktelemetryConsentV3";
|
||||||
|
target = "PDX/SDK/victoria3/telemetry_consent.json";
|
||||||
|
settings = {
|
||||||
|
telemetry_consent_choice = "denied";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
victoria3Settings = mkMergedJson {
|
||||||
|
name = "victoria3-settings";
|
||||||
|
target = "${pdxrel}/Victoria 3/pdx_settings.json";
|
||||||
|
settings = {
|
||||||
|
Account = {
|
||||||
|
telemetry_consent = false;
|
||||||
|
};
|
||||||
|
game = {
|
||||||
|
save_on_exit = true;
|
||||||
|
};
|
||||||
|
Theme = {
|
||||||
|
daynight_cycle = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
prismLauncherCfg = mkMergedIni {
|
||||||
|
name = "prism-launcher-config";
|
||||||
|
target = ".local/share/PrismLauncher/prismlauncher.cfg";
|
||||||
|
settings = {
|
||||||
|
General = {
|
||||||
|
Language = "zh";
|
||||||
|
ApplicationTheme = "Adwaita-Dark";
|
||||||
|
ShowConsoleOnError = true;
|
||||||
|
|
||||||
|
PermGen = 128;
|
||||||
|
MinMemAlloc = 512;
|
||||||
|
MaxMemAlloc = 4096;
|
||||||
|
|
||||||
|
ShowGlobalGameTime = true;
|
||||||
|
RecordGameTime = true;
|
||||||
|
ShowGameTime = true;
|
||||||
|
ShowGameTimeWithoutDays = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
ryujinxConfig = mkMergedJson {
|
||||||
|
name = "ryujinx-config";
|
||||||
|
target = ".config/Ryujinx/Config.json";
|
||||||
|
settings = {
|
||||||
|
game_dir = [
|
||||||
|
"${config.home.homeDirectory}/Games/ROM/Nintendo - Nintendo Switch"
|
||||||
|
];
|
||||||
|
"language_code" = "zh_CN";
|
||||||
|
"check_updates_on_start" = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
steam
|
steam
|
||||||
# Steam Adwaita Theme
|
# Steam Adwaita Theme
|
||||||
|
|
@ -13,11 +108,26 @@
|
||||||
cemu
|
cemu
|
||||||
# Game launcher and library manager
|
# Game launcher and library manager
|
||||||
lutris
|
lutris
|
||||||
|
# Steam Achievement Manager
|
||||||
|
samira
|
||||||
|
|
||||||
# Memory Scanner (Cheat Engine Alt.)
|
# Memory Scanner (Cheat Engine Alt.)
|
||||||
scanmem
|
scanmem
|
||||||
];
|
];
|
||||||
imports = [
|
imports = [
|
||||||
../programs/retroarch.nix
|
../programs/retroarch.nix
|
||||||
|
paradoxLauncherUserSettings
|
||||||
|
victoria3Settings
|
||||||
|
pdxSdkSettingsEU5
|
||||||
|
pdxSdkSettingsV3
|
||||||
|
pdxSdkTelemetryEU5
|
||||||
|
pdxSdkTelemetryV3
|
||||||
|
prismLauncherCfg
|
||||||
|
ryujinxConfig
|
||||||
];
|
];
|
||||||
|
xdg.dataFile = {
|
||||||
|
"Paradox Interactive/launcherpath".text = ''
|
||||||
|
${config.home.homeDirectory}/.local/share/paradoxlauncher
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
''{"wm_class":"dev.benz.walker","scratch_layer":true}''
|
''{"wm_class":"dev.benz.walker","scratch_layer":true}''
|
||||||
''{"wm_class":"org.pulseaudio.pavucontrol","scratch_layer":true}''
|
''{"wm_class":"org.pulseaudio.pavucontrol","scratch_layer":true}''
|
||||||
''{"wm_class":"mpv","scratch_layer":true}''
|
''{"wm_class":"mpv","scratch_layer":true}''
|
||||||
|
''{"wm_class":"org.gnome.NautilusPreviewer","scratch_layer":true}''
|
||||||
''{"wm_class":"terminal-popup","scratch_layer":true}''
|
''{"wm_class":"terminal-popup","scratch_layer":true}''
|
||||||
''{"wm_class":"fsearch","scratch_layer":true}''
|
''{"wm_class":"fsearch","scratch_layer":true}''
|
||||||
''{"wm_class":"QQ","title":"资料卡","scratch_layer":true}''
|
''{"wm_class":"QQ","title":"资料卡","scratch_layer":true}''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue