refactor(tf2): Split off tf2.nix into separate repo

This commit is contained in:
Madeleine Sydney
2025-04-02 08:28:25 -06:00
parent 21fb7efde0
commit 3e0ed596da
6 changed files with 51 additions and 249 deletions

36
flake.lock generated Executable file → Normal file
View File

@@ -679,6 +679,22 @@
"type": "github"
}
},
"nixpkgs_12": {
"locked": {
"lastModified": 1743568003,
"narHash": "sha256-ZID5T65E8ruHqWRcdvZLsczWDOAWIE7om+vQOREwiX0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b7ba7f9f45c5cd0d8625e9e217c28f8eb6a19a76",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1742669843,
@@ -868,6 +884,8 @@
"stylix": "stylix",
"sydnix-cli": "sydnix-cli",
"vpn-confinement": "vpn-confinement"
"sydnix-cli": "sydnix-cli",
"tf2-nix": "tf2-nix"
}
},
"sops-nix": {
@@ -984,6 +1002,24 @@
"type": "github"
}
},
"tf2-nix": {
"inputs": {
"nixpkgs": "nixpkgs_12"
},
"locked": {
"lastModified": 1744277918,
"narHash": "sha256-8C+wwrjYvatRDXE8HLeN0rUnfOW/ehqpBKhOkx4/mm0=",
"owner": "msyds",
"repo": "tf2-nix",
"rev": "e40d15248908d22041dbea7e3f693972a5913c2f",
"type": "gitlab"
},
"original": {
"owner": "msyds",
"repo": "tf2-nix",
"type": "gitlab"
}
},
"tinted-foot": {
"flake": false,
"locked": {

View File

@@ -28,6 +28,7 @@
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
tf2-nix.url = "gitlab:msyds/tf2-nix";
};
outputs = { self, nixpkgs, ... }@inputs:

View File

@@ -1,24 +0,0 @@
{ 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

@@ -1,99 +0,0 @@
{ 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

@@ -1,116 +0,0 @@
{ 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

@@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, inputs, ... }:
# Launch options: -novid -nojoy -nosteamcontroller -nohltv -particles 1 -precachefontchars -noquicktime -console -windowed -noborder
@@ -10,21 +10,25 @@ in {
config = lib.mkIf cfg.enable
(let
tf2pkgs = pkgs.callPackage ../../tf2/packages.nix {};
in {
tf2 = {
enable = true;
packages = with tf2pkgs; [
tf2pkgs = inputs.tf2-nix.packages.x86_64-linux;
my-config = pkgs.symlinkJoin {
name = "tf2-files";
paths = 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)
deerhud
./tf2/my-config
./tf2/quake-hitsounds
];
};
});
in {
home.file."tf" = {
recursive = true;
source = my-config;
};
});
}