feat: tf2.nix

This commit is contained in:
Madeleine Sydney
2025-03-30 04:52:35 -06:00
parent 52f56d5437
commit 7f6dcf010f
21 changed files with 507 additions and 0 deletions

View File

@@ -7,6 +7,10 @@ in {
};
config = lib.mkIf cfg.enable {
# Steam is quite buggy and doesn't play too nicely with Impermanence:
# 1. We must use symlinks, rather than bind-mounts.
# 2. The symlinks *must not be present* during Steam's first launch
# (i.e. when it installs itself). Horrible bugs ensue.
sydnix.impermanence.directories = [
# Steam has a number of mysterious issues when its state directories are
# symlinks. Most bizarrely, I've experienced complementory issues;
@@ -14,6 +18,7 @@ in {
# symlinks. Thanks, Valve!
#
# https://github.com/ValveSoftware/steam-for-linux/issues/10552
# https://github.com/nix-community/impermanence/issues/165
{ directory = ".local/share/Steam"; method = "symlink"; }
{ directory = ".steam"; method = "symlink"; }
];

24
modules/home/tf2.nix Normal file
View File

@@ -0,0 +1,24 @@
{ config, lib, pkgs, ... }:
let cfg = config.tf2;
in {
options.tf2 = {
enable = lib.mkEnableOption "Team Fortress 2 configuration";
packages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
};
};
config = lib.mkIf cfg.enable
(let gameDir = ".local/share/Steam/steamapps/common/Team Fortress 2";
in {
home.file."tf" = {
recursive = true;
source = pkgs.symlinkJoin {
name = "tf2-files";
paths = cfg.packages;
};
};
});
}

View File

@@ -0,0 +1,99 @@
{ lib
, runCommand
, fetchFromGitHub
, fetchurl
, fetchzip
, ... }:
let
mkTf2Package =
{ pname
, version ? null
, cfg ? []
, custom ? []
, env ? {}
}@args:
let name = "${pname}${lib.optionalString (version != null) "-${version}"}";
in runCommand name env ''
${lib.toShellVar "cfgs" cfg}
${lib.toShellVar "customs" custom}
set -xe
mkdir -p $out/cfg $out/custom
for i in "''${cfgs[@]}"; do
ln -s "$i" "$out/cfg/$(basename "$i")"
done
for i in "''${customs[@]}"; do
ln -s "$i" "$out/custom/$(basename "$i")"
done
'';
mkCfg = name: body:
runCommand name {} ''
${lib.toShellVar "name" name}
mkdir -p $out/cfg "$(dirname "$out/cfg/$name")"
tee "$out/cfg/$name.cfg" << SUPER_UNIQUE_EOF
// Generated by tf2.nix
${body}
SUPER_UNIQUE_EOF
'';
mkTf2PackageFromDir = path:
runCommand "tf2-dir" {} ''
cp -r "${path}" $out
'';
fetchFromGameBanana =
{ id
, hash
}:
fetchzip {
url = "https://gamebanana.com/dl/${id}";
extension = "zip";
inherit hash;
};
mastercomfig = import ./packages/mastercomfig.nix {
inherit mkTf2Package;
inherit fetchurl;
};
in {
inherit mkTf2Package mastercomfig mkCfg mkTf2PackageFromDir;
huds.deerhud = mkTf2Package {
pname = "deerhud";
version = "78a24ef";
custom = [
(fetchFromGitHub {
name = "deerhud";
owner = "DeerUwU";
repo = "deerhud-tf2";
rev = "78a24effbc66bc78b4bb557228eaa0195db3270c";
hash = "sha256-uwKRilkEPHk1snjH/n9u32dMXr3cXjYN06cfthpZe7g=";
})
];
};
loadouts-script = mkTf2Package rec {
pname = "tf2-loadouts-script";
version = "3.1";
custom = [
(fetchurl {
url = "https://github.com/jooonior/tf2-loadouts-script/releases/download/v${version}/loadouts.vpk";
hash = "sha256-qMDQe/lLZz5YdH6kvG7vNKHUxPvId4AMqu/hFqr/Sd8=";
})
];
};
improved-crosshairs = mkTf2Package {
pname = "improved-crosshairs";
custom = [
(fetchFromGameBanana {
id = "1047153";
hash = "sha256-ULcSfxuiGY1YCE1zQ693183F7ZRC11tYhvDMJKyzL1A=";
})
];
};
}

View File

@@ -0,0 +1,116 @@
{ fetchurl
, mkTf2Package
}:
let
mastercomfigVersion = "9.10.3";
releasesUrl = version:
"https://github.com/mastercomfig/mastercomfig/releases/download/${version}";
fetchMastercomfig = { version, file, hash ? "" }:
fetchurl {
url = "${releasesUrl version}/${file}";
inherit hash;
};
mkMastercomfig =
type:
{ name
, hash
, file ? "mastercomfig-${name}-${type}.vpk"
, version ? mastercomfigVersion
}:
mkTf2Package {
pname = "mastercomfig-${name}-${type}";
inherit version;
custom = [
(fetchMastercomfig {
inherit version file hash;
})
];
};
mkMastercomfigAddon = mkMastercomfig "addon";
mkMastercomfigPreset = mkMastercomfig "preset";
in {
addons.disable-pyroland = mkMastercomfigAddon {
name = "disable-pyroland";
hash = "sha256-cEFaXSXwlHwm7BnkSLmG4vAPYhL1O0XwNG0UpTnDFY8=";
};
addons.flat-mouse = mkMastercomfigAddon {
name = "flat-mouse";
hash = "sha256-v2Url+m8dzXIrs8mz5VZWRqwqSSaxyH7t2vDvT10cdg=";
};
presets.high = mkMastercomfigPreset {
name = "high";
hash = "sha256-704aEg1Gyl5vI6Y6VTmlUEiP70PjrF6/VlxsrkkepWs=";
};
presets.low = mkMastercomfigPreset {
name = "low";
hash = "sha256-CpIbjy1dzNCEa583DthygkIQ5aq7Wp2QOJGANC2IGNs=";
};
addons.lowmem = mkMastercomfigAddon {
name = "lowmem";
hash = "sha256-21iyJ4Zg+p5qES05FP2fMO7/p3YrrIkNp2GM2oEjT4E=";
};
presets.medium-high = mkMastercomfigPreset {
name = "medium-high";
hash = "sha256-pS1KcFxxB/oT9DcopZyu77nr4td6x2mDrEFVNOPmtws=";
};
presets.medium-low = mkMastercomfigPreset {
name = "medium-low";
hash = "sha256-P9Zk9IZVpX1hkAcdpNvKfzP2P+TDPNRwwv4I8uM+WU4=";
};
presets.medium = mkMastercomfigPreset {
name = "medium";
hash = "sha256-yEcxPkU/0vJn7vy3n2ViYdTCBV3O9gX57fMQQZYlm3I=";
};
addons.no-footsteps = mkMastercomfigAddon {
name = "no-footsteps";
hash = "sha256-7WIWwV2PnwRM79I7vOdfRggQi/NUS+6GHkAAyo8ap2I=";
};
addons.no-soundscapes = mkMastercomfigAddon {
name = "no-soundscapes";
hash = "sha256-Qp7QW9zZXpX7zrK+Fmpf428lU7Mc86sMn6+5Syhnxz0=";
};
addons.no-tutorial = mkMastercomfigAddon {
name = "no-tutorial";
hash = "sha256-sA3kN2iNe5bwh+954ef+sV0hjMdMZLs6IPgsHDi5oXE=";
};
presets.none = mkMastercomfigPreset {
name = "none";
hash = "sha256-FQ8o4fxUkIAqlFPZPULScwDBaQjc88NiO579IaFTikA=";
};
addons.null-canceling-movement = mkMastercomfigAddon {
name = "null-canceling-movement";
hash = "sha256-B3pHn80lMRN4q5hF/JSAdzDLTnyh7MNbYzMURrYmXxU=";
};
addons.transparent-viewmodels = mkMastercomfigAddon {
name = "transparent-viewmodels";
hash = "sha256-nsUBSsGHXM+xwecixZvhisbifLqkqSyF7kIkJFmq6ow=";
};
presets.ultra = mkMastercomfigPreset {
name = "ultra";
hash = "sha256-VfSFxRuZtYLuNrtX6X7BEMtL6wMbFyela7zbmZurlCw=";
};
presets.very-low = mkMastercomfigPreset {
name = "very-low";
hash = "sha256-faGnju5aPovl++kAh2HNkkroUoMz9/Fx6kSgb3IBRfg=";
};
}

View File

@@ -10,4 +10,6 @@
(require 'syd-lang-sql)
(require 'syd-lang-idris2)
(use-package tf2-conf-mode)
(provide 'syd-lang)

View File

@@ -0,0 +1,30 @@
{ config, lib, pkgs, ... }:
# Launch options: -novid -nojoy -nosteamcontroller -nohltv -particles 1 -precachefontchars -noquicktime -console -windowed -noborder
let cfg = config.sydnix.users.crumb.tf2;
in {
options.sydnix.users.crumb.tf2 = {
enable = lib.mkEnableOption "Madeleine's Team Fortress 2 config";
};
config = lib.mkIf cfg.enable
(let
tf2pkgs = pkgs.callPackage ../../tf2/packages.nix {};
in {
tf2 = {
enable = true;
packages = with tf2pkgs; [
mastercomfig.presets.medium-low
mastercomfig.addons.flat-mouse
mastercomfig.addons.no-tutorial
mastercomfig.addons.null-canceling-movement
improved-crosshairs
loadouts-script
huds.deerhud
(tf2pkgs.mkTf2PackageFromDir ./tf2/my-config)
(tf2pkgs.mkTf2PackageFromDir ./tf2/quake-hitsounds)
];
};
});
}

View File

@@ -0,0 +1,5 @@
exec loadouts/load
exec overrides/binds.cfg
exec overrides/settings.cfg

View File

@@ -0,0 +1,106 @@
unbindall
bind f5 loadouts.A
bind f6 loadouts.B
bind f7 loadouts.C
bind f8 loadouts.D
bind alt loadouts.resup
// Quick-switch
alias +melee "slot3"
alias -melee "slot1"
bind mouse4 +melee
alias +secondary "slot2"
alias -secondary "slot1"
bind mouse5 +secondary
// bhop
bind "mwheelup" "+jump"
bind "mwheeldown" "+jump"
// q/e scroll
bind q invprev
bind e invnext
// chat
bind "t" "say"
bind "y" "say_team"
bind "p" "say_party"
bind "v" "+voicerecord"
// use null-movement script included w/ mastercomfig
bind w +mf
bind a +ml
bind s +mb
bind d +mr
// Class keypad
bind kp_end "join_class scout"
bind kp_downarrow "join_class soldier"
bind kp_pgdn "join_class pyro"
bind kp_leftarrow "join_class demoman"
bind kp_5 "join_class heavyweapons"
bind kp_rightarrow "join_class engineer"
bind kp_home "join_class medic"
bind kp_uparrow "join_class sniper"
bind kp_pgup "join_class spy"
// Crouch-jump
alias +cj "+duck; +jump"
alias -cj "-duck; -jump"
bind space +cj
bind "0" "slot10"
bind "1" "slot1"
bind "2" "slot2"
bind "3" "slot3"
bind "4" "slot4"
bind "5" "slot5"
bind "6" "slot6"
bind "7" "slot7"
bind "8" "slot8"
bind "9" "slot9"
bind "b" "scrapped"
bind "c" "voice_menu_3"
bind "f" "+inspect"
bind "g" "+taunt"
bind "h" "+quickswitch"
bind "i" "showmapinfo"
bind "j" "cl_trigger_first_notification"
bind "k" "cl_decline_first_notification"
bind "l" "dropitem"
bind "m" "open_charinfo_direct"
bind "n" "open_charinfo_backpack"
bind "o" "+attack3"
bind "r" "+reload"
bind "u" "kill"
bind "v" "+use_action_slot_item"
bind "x" "voice_menu_2"
bind "z" "voice_menu_1"
bind "[" "callvote"
bind "]" "toggle r_drawviewmodel"
bind "'" "+moveup"
bind "`" "toggleconsole"
bind "," "changeclass"
bind "." "changeteam"
bind "/" "+movedown"
bind "\" "save_replay"
bind "-" "abuse_report_queue"
bind "SPACE" "+jump"
bind "TAB" "+showscores"
bind "ESCAPE" "cancelselect"
bind "INS" "show_quest_log"
bind "END" "centerview"
bind "PAUSE" "pause"
bind "SHIFT" "+duck"
bind "RSHIFT" "disguiseteam"
bind "F3" "show_matchmaking"
bind "F10" "quit prompt"
bind "F11" "vr_reset_home_pos"
bind "F12" "replay_togglereplaytips"
bind "MOUSE1" "+attack"
bind "MOUSE2" "+attack2"
bind "MOUSE3" "+qsr_slot3_1"

View File

@@ -0,0 +1,8 @@
exec overrides/binds
bind space +jump
alias +secondary "slot1"
alias -secondary "slot2"
loadouts.demoman

View File

@@ -0,0 +1,14 @@
exec overrides/binds.cfg
alias sentry "destroy 2 0; build 2 0;"
alias dispenser "destroy 0 0; build 0 0;"
alias tp_entrance "destroy 1 0; build 1 0;"
alias tp_exit "destroy 1 1; build 1 1;"
bind 4 dispenser
bind mouse3 sentry
bind 5 tp_entrance
bind 6 tp_exit
loadouts.engineer

View File

@@ -0,0 +1,2 @@
exec overrides/binds.cfg
loadouts.heavyweapons

View File

@@ -0,0 +1,34 @@
exec overrides/binds
alias s1 "slot1; viewmodel_fov 70"
alias s2 "slot2; viewmodel_fov 0"
alias s3 "slot3; viewmodel_fov 70"
bind 1 s1
bind 2 s2
bind 3 s3
alias +uber "s2; +attack2; dropitem; say_team !!! bleaaaat we üsed !!!"
alias -uber "-attack2"
bind mouse2 +uber
alias mask "voicemenu 0 1; say_team !!! masking (98%) !!!"
bind q mask
alias fake "voicemenu 1 7; say_team !!! faking . i love lying !!!"
bind b fake
// medic radar
hud_medicautocallers 1
alias autocall_default "hud_medicautocallersthreshold 60"
alias autocall_all "hud_medicautocallersthreshold 150"
alias +radar "autocall_all"
alias -radar "autocall_default"
bind r "+radar"
alias +secondary s1
alias -secondary s2
alias +melee s3
alias -melee s2
loadouts.medic

View File

@@ -0,0 +1,20 @@
exec overrides/binds.cfg
alias s1 "slot1; viewmodel_fov 0"
alias s2 "slot2; viewmodel_fov 70"
alias s3 "slot3; viewmodel_fov 70"
bind 1 s1
bind 2 s2
bind 3 s3
alias +secondary s2
alias -secondary s1
alias +melee s3
alias -melee s1
bind mouse5 +secondary
bind mouse4 +melee
loadouts.pyro

View File

@@ -0,0 +1,2 @@
exec overrides/binds
loadouts.scout

View File

@@ -0,0 +1,13 @@
fov_desired 90
// Viewmodels
cl_flipviewmodels 1
viewmodel_fov 70
// Crosshair
cl_crosshair_file ""
cl_crosshair_scale 40
cl_crosshair_red 251
cl_crosshair_green 130
cl_crosshair_blue 175

View File

@@ -0,0 +1,4 @@
exec overrides/binds.cfg
loadouts.sniper

View File

@@ -0,0 +1,6 @@
exec overrides/binds.cfg
bind space +jump
loadouts.soldier

View File

@@ -0,0 +1,16 @@
exec overrides/binds
bind b "disguise 1 1"
bind 4 "lastdisguise"
alias +secondary "slot1"
alias -secondary "slot3"
alias +melee "slot4"
alias -melee "slot3"
// remove disguise
bind c "disguise 8 -2"
loadouts.spy