feat: Fix improved-crosshairs and allow customisation of alternatives

This commit is contained in:
Madeleine Sydney
2025-04-17 03:57:16 -06:00
parent 2b3bc04751
commit 36fb39c38b
4 changed files with 47 additions and 15 deletions

View File

@@ -41,6 +41,8 @@ in lib.mergeAttrsList [
{ mastercomfig = callPackage ./mastercomfig.nix {}; }
{ huds = callPackage ./huds {}; }
{ maps = callPackage ./maps {}; }
(callPackage ./misc.nix {})
(builtins.mapAttrs
(_: v: callPackage v {})
(import ./misc {inherit lib;}))
(callPackage ./scripts.nix {})
]

View File

@@ -1,14 +0,0 @@
{ fetchFromGameBanana, mkTf2Config, ... }:
{
improved-crosshairs = mkTf2Config {
pname = "improved-crosshairs";
custom = [
(fetchFromGameBanana {
name = "improved-crosshairs";
id = "1047153";
hash = "sha256-ULcSfxuiGY1YCE1zQ693183F7ZRC11tYhvDMJKyzL1A=";
})
];
};
}

View File

@@ -0,0 +1,10 @@
{ lib, ... }:
lib.mapAttrs'
(file: _:
lib.nameValuePair
(lib.removeSuffix ".nix" file)
(import ./${file}))
(lib.filterAttrs
(file: _: lib.hasSuffix ".nix" file && file != "default.nix")
(builtins.readDir ./.))

View File

@@ -0,0 +1,34 @@
{ fetchFromGameBanana
, stdenv
, lib
# Alternate crosshairs to use. See their README.
, alternates ? []
}:
stdenv.mkDerivation {
pname = "improved-crosshairs";
version = "2.0";
src = fetchFromGameBanana {
name = "improved-crosshairs";
id = "1047153";
hash = "sha256-ULcSfxuiGY1YCE1zQ693183F7ZRC11tYhvDMJKyzL1A=";
};
buildPhase = ''
${lib.toShellVar "alternates" alternates}
dest_dir="Crosshairs/materials/vgui/replay/thumbnails/"
for alt in "''${alternates[@]}"; do
dest="$dest_dir/$(sed -e 's/\(.*\) \[.*\]$/\1/' <<< "$alt").vtf"
src="Alternates/$alt.vtf"
if [ ! -e "$src" ]; then
echo "Alternate '$alt' does not exist!"
exit 1
else
mv "$src" "$dest"
fi
done
'';
installPhase = ''
mkdir -p $out/custom
mv Crosshairs "$out/custom/improved-crosshairs"
'';
}