Files
nix-config/packages/proton-cachyos/default.nix
2026-04-05 19:10:23 -05:00

76 lines
1.9 KiB
Nix

{
stdenvNoCC,
lib,
fetchurl,
fetchzip,
namespace,
# Repo metadata
owner ? "CachyOS",
repo ? "proton-cachyos",
# Variant selection (null -> use defaultVariant from version.json)
variant ? "cachyos-v4",
# Packaging/customization knobs
toolPattern ? "proton-.*",
tarballPrefix ? "proton-",
tarballSuffix ? "-x86_64_v4.tar.xz",
releasePrefix ? "cachyos-",
releaseSuffix ? "-slr",
}:
let
inherit (lib.trivial) importJSON;
inherit (lib.${namespace}) selectVariant;
versionSpec = importJSON ./version.json;
selected = selectVariant versionSpec variant null;
vars = selected.variables or { };
toolTitle = "proton-${variant}-latest";
releaseVersion = "${releasePrefix}${vars.base}-${vars.release}${releaseSuffix}";
homepage = "https://${owner}/${repo}";
url = "${homepage}/releases/download/${releaseVersion}/${tarballPrefix}${releaseVersion}${tarballSuffix}";
# Choose fetcher based on file type
intake =
if lib.hasSuffix ".zip" url then
{
fetcher = fetchzip;
input = "$src/*.tar.xz";
}
else
{
fetcher = fetchurl;
input = "$src";
};
in
stdenvNoCC.mkDerivation {
name = repo;
version = "${vars.base}.${vars.release}";
src = intake.fetcher {
inherit url;
hash = selected.sources.proton.hash;
};
buildCommand = ''
mkdir -p $out/bin
tar -C $out/bin --strip=1 -x -f ${intake.input}
''
# Allow to keep the same name between updates
+ lib.optionalString (toolTitle != null) ''
sed -i -r 's|"${toolPattern}"|"${toolTitle}"|' $out/bin/compatibilitytool.vdf
'';
passthru = { };
meta = with lib; {
inherit homepage;
description = "Compatibility tool for Steam Play based on Wine and additional components (patched and built by ${owner})";
license = licenses.bsd3;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [
pedrohlc
];
};
}