This commit is contained in:
mjallen18
2026-01-21 21:43:31 -06:00
parent 94c3d6d6ff
commit e2e2d814fe
23 changed files with 478 additions and 572 deletions

View File

@@ -9,7 +9,8 @@ let
getAttr
attrNames
toString
replaceStrings;
replaceStrings
;
mapAttrs = lib.mapAttrs;
recursiveUpdate = lib.recursiveUpdate;
@@ -18,14 +19,16 @@ let
deepMerge = a: b: recursiveUpdate a b;
# Merge component sources: base.sources overlaid by overrides (component-wise deep merge).
mergeSources = baseSources: overrides:
baseSources //
mapAttrs (name: ov:
if hasAttr name baseSources then deepMerge (getAttr name baseSources) ov else ov
mergeSources =
baseSources: overrides:
baseSources
// mapAttrs (
name: ov: if hasAttr name baseSources then deepMerge (getAttr name baseSources) ov else ov
) overrides;
# Apply a single variant overlay (variables + sources).
applyVariantOnce = selected: variant:
applyVariantOnce =
selected: variant:
let
vVars = if variant ? variables then variant.variables else { };
vSrcs = if variant ? sources then variant.sources else { };
@@ -36,7 +39,8 @@ let
};
# Apply platform-specific overrides if present for the given system.
applyPlatforms = selected: variant: system:
applyPlatforms =
selected: variant: system:
if system == null || !(variant ? platforms) || !(hasAttr system variant.platforms) then
selected
else
@@ -51,7 +55,8 @@ let
};
# Resolve variant chain via inherits (ancestor first), then apply platforms.
resolveVariant = spec: baseSelected: variantName: system:
resolveVariant =
spec: baseSelected: variantName: system:
if variantName == null || !(spec ? variants) || !(hasAttr variantName spec.variants) then
baseSelected
else
@@ -64,7 +69,8 @@ let
applyPlatforms withVariant v system;
# Render ${var} substitutions in any string within attrs/lists.
renderValue = value: vars:
renderValue =
value: vars:
if isString value then
let
keys = attrNames vars;
@@ -80,23 +86,26 @@ let
value;
# Decide fetcher for URL type based on optional extra.unpack hint.
useFetchZip = comp:
comp ? extra && comp.extra ? unpack && comp.extra.unpack == "zip";
useFetchZip = comp: comp ? extra && comp.extra ? unpack && comp.extra.unpack == "zip";
# Build a single src from a rendered component spec.
mkSrcFromRendered = comp:
mkSrcFromRendered =
comp:
let
fetcher = if comp ? fetcher then comp.fetcher else "none";
in
if fetcher == "github" then
pkgs.fetchFromGitHub ({
pkgs.fetchFromGitHub (
{
owner = comp.owner;
repo = comp.repo;
# Allow tag as rev (ignore null/empty tag)
rev = if comp ? tag && comp.tag != null && comp.tag != "" then comp.tag else comp.rev;
fetchSubmodules = if comp ? submodules then comp.submodules else false;
hash = comp.hash;
} // lib.optionalAttrs (comp ? name) { name = comp.name; })
}
// lib.optionalAttrs (comp ? name) { name = comp.name; }
)
else if fetcher == "git" then
pkgs.fetchgit {
url = comp.url;
@@ -110,11 +119,17 @@ let
in
if useFetchZip comp then
pkgs.fetchzip (
{ inherit url; hash = comp.hash; }
{
inherit url;
hash = comp.hash;
}
// lib.optionalAttrs (comp ? extra && comp.extra ? stripRoot) { stripRoot = comp.extra.stripRoot; }
)
else
pkgs.fetchurl { inherit url; hash = comp.hash; }
pkgs.fetchurl {
inherit url;
hash = comp.hash;
}
else if fetcher == "pypi" then
pkgs.python3Packages.fetchPypi {
pname = comp.name;
@@ -125,7 +140,8 @@ let
# fetcher == "none": pass-through (e.g., linux version/hash consumed by custom logic)
comp;
in rec {
in
rec {
/*
Select a variant from a loaded version.json specification.
@@ -135,9 +151,14 @@ in rec {
- variantName: string or null (when null, uses spec.defaultVariant if present)
- system: string like "x86_64-linux" or null (to apply platforms overrides)
*/
selectVariant = spec: variantName: system:
selectVariant =
spec: variantName: system:
let
chosen = if variantName != null then variantName else (if spec ? defaultVariant then spec.defaultVariant else null);
chosen =
if variantName != null then
variantName
else
(if spec ? defaultVariant then spec.defaultVariant else null);
baseSelected = {
variables = if spec ? variables then spec.variables else { };
sources = if spec ? sources then spec.sources else { };
@@ -155,9 +176,12 @@ in rec {
Render a component with variables and then build its src (or pass-through for fetcher "none").
Prefer using mkAllSources, which handles rendering for all components.
*/
mkSrc = comp: variables:
let rendered = renderValue comp variables;
in mkSrcFromRendered rendered;
mkSrc =
comp: variables:
let
rendered = renderValue comp variables;
in
mkSrcFromRendered rendered;
/*
Produce an attrset of all sources for a selected spec:
@@ -167,15 +191,16 @@ in rec {
Returns:
{ componentName = src | renderedComp (for "none"); ... }
*/
mkAllSources = selected:
mapAttrs (_name: comp:
if comp ? fetcher && comp.fetcher == "none"
then renderValue comp selected.variables
else mkSrc (renderValue comp selected.variables) selected.variables
mkAllSources =
selected:
mapAttrs (
_name: comp:
if comp ? fetcher && comp.fetcher == "none" then
renderValue comp selected.variables
else
mkSrc (renderValue comp selected.variables) selected.variables
) selected.sources;
/*
Expose deepMerge for convenience (right-biased).
*/
# Expose deepMerge for convenience (right-biased).
inherit deepMerge;
}

View File

@@ -1,4 +1,9 @@
{ config, namespace, lib, ... }:
{
config,
namespace,
lib,
...
}:
let
cfg = config.${namespace}.programs.hyprland;
in

View File

@@ -15,7 +15,7 @@ let
};
in
{
bcachefs-tools = prev.bcachefs-tools.overrideAttrs (old: rec {
bcachefs-tools = prev.bcachefs-tools.overrideAttrs (_old: rec {
version = "1.35.2";
src = prev.fetchFromGitHub {
owner = "koverstreet";

View File

@@ -1,6 +1,5 @@
{
inputs,
self,
namespace,
...
}:
@@ -27,9 +26,11 @@ let
linux-rpi5 = final.linuxPackagesFor (final.${namespace}.linux-rpi);
linux-rpi4 = final.linuxPackagesFor (final.${namespace}.linux-rpi.override {
linux-rpi4 = final.linuxPackagesFor (
final.${namespace}.linux-rpi.override {
rpiVersion = 4;
});
}
);
in
{
${namespace} = prev.${namespace} // {
@@ -38,19 +39,19 @@ in
linuxPackages_rpi5-lts = linux-rpi5;
linuxPackages_rpi4-lts = linux-rpi4;
linuxPackages_rpi5-latest = linux-rpi5.overrideAttrs (old: {
linuxPackages_rpi5-latest = linux-rpi5.overrideAttrs (_old: {
modDirVersion = "6.18.4";
src = linux618Src;
});
linuxPackages_rpi5-rc = linux-rpi5.overrideAttrs (old: {
linuxPackages_rpi5-rc = linux-rpi5.overrideAttrs (_old: {
modDirVersion = "6.19.0-rc5";
src = linux619Src;
});
linuxPackages_rpi4-latest = linux-rpi4.overrideAttrs (old: {
linuxPackages_rpi4-latest = linux-rpi4.overrideAttrs (_old: {
modDirVersion = "6.18.4";
src = linux618Src;
});
linuxPackages_rpi4-rc = linux-rpi4.overrideAttrs (old: {
linuxPackages_rpi4-rc = linux-rpi4.overrideAttrs (_old: {
modDirVersion = "6.19.0-rc5";
src = linux619Src;
});

View File

@@ -23,7 +23,8 @@ let
# Source Versions #
# ######################################################
versionSpec = importJSON ./version.json;
mkVersions = selected:
mkVersions =
selected:
let
s = selected.sources;
vars = selected.variables or { };

View File

@@ -18,11 +18,7 @@
final,
}:
let
version =
if stdenv.isAarch64 then
"6.12.47"
else
cachyConfig.versions.linux.version;
version = if stdenv.isAarch64 then "6.12.47" else cachyConfig.versions.linux.version;
# Single-value optional attr
optionalAttr =
key: pred: value:

View File

@@ -9,11 +9,7 @@
commonMakeFlags,
}:
let
version =
if stdenv.isAarch64 then
"6.12.47"
else
cachyConfig.versions.linux.version;
version = if stdenv.isAarch64 then "6.12.47" else cachyConfig.versions.linux.version;
majorMinor = lib.versions.majorMinor version;
@@ -37,10 +33,8 @@ let
}
else
(
if stdenv.isAarch64
then
if stdenv.isAarch64 then
let
modDirVersion = "6.12.47";
tag = "stable_20250916";
hash = "sha256-Rjn+eWl5cLcc9wgjS3HYVaWM5eKMN3pPfPbsu+QGR/M=";
in

View File

@@ -1,5 +1,4 @@
{
callPackage,
stdenvNoCC,
lib,
fetchurl,
@@ -8,8 +7,6 @@
# Repo metadata
owner ? "CachyOS",
repo ? "proton-cachyos",
# Behavior
withUpdateScript ? true,
# Variant selection (null -> use defaultVariant from version.json)
variant ? null,
# Packaging/customization knobs
@@ -66,24 +63,7 @@ stdenvNoCC.mkDerivation {
sed -i -r 's|"${toolPattern}"|"${toolTitle}"|' $out/bin/compatibilitytool.vdf
'';
passthru =
if withUpdateScript then
{
updateScript = callPackage ./update.nix {
inherit
tarballPrefix
tarballSuffix
releasePrefix
releaseSuffix
owner
repo
;
# Prefer explicit variant, otherwise use defaultVariant from the spec
variant = if variant != null then variant else (versionSpec.defaultVariant or "cachyos");
};
}
else
{ };
passthru = { };
meta = with lib; {
inherit homepage;

View File

@@ -1,95 +0,0 @@
{
writeShellScript,
lib,
coreutils,
findutils,
gnugrep,
curl,
jq,
git,
nix,
nix-prefetch-git,
moreutils,
yq,
# Config
tarballPrefix,
tarballSuffix,
releasePrefix,
releaseSuffix,
owner,
repo,
# New: which variant to update (defaults to version.json's defaultVariant)
variant ? null,
}:
let
path = lib.makeBinPath [
coreutils
curl
findutils
gnugrep
jq
moreutils
git
nix-prefetch-git
nix
yq
];
in
writeShellScript "update-${repo}" ''
set -euo pipefail
PATH=${path}
repoRoot="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
versionFile="$repoRoot/packages/proton-cachyos/version.json"
# Determine variant to update (prefer CLI arg, else defaultVariant in file)
variantEff="${variant:-}"
if [ -z "$variantEff" ]; then
variantEff="$(jq -r '.defaultVariant // empty' "$versionFile")"
fi
if [ -z "$variantEff" ]; then
variantEff="cachyos"
fi
# Read current values from the unified version.json
localBase="$(jq -r --arg v "$variantEff" '.variants[$v].variables.base' "$versionFile")"
localRelease="$(jq -r --arg v "$variantEff" '.variants[$v].variables.release' "$versionFile")"
localHash="$(jq -r --arg v "$variantEff" '.variants[$v].sources.proton.hash' "$versionFile")"
# Discover latest release tag
latestVer="$(
curl -fsSL "https://github.com/${owner}/${repo}/releases.atom" \
| xq -r '.feed.entry[].link."@href"' \
| grep -Po "(?<=/)${releasePrefix}[^/]+${releaseSuffix}$" \
| head -n 1
)"
if [ "${releasePrefix}''${localBase}-''${localRelease}${releaseSuffix}" = "$latestVer" ]; then
echo "No update needed for variant '$variantEff' (${localBase}.${localRelease})."
exit 0
fi
latestBase="$(echo "$latestVer" | grep -Po "(?<=^${releasePrefix})[^-]+")"
latestRelease="$(echo "$latestVer" | grep -Po "(?<=-)[^-]+(?=${releaseSuffix}$)")"
artifactUrl="https://github.com/${owner}/${repo}/releases/download/''${latestVer}/${tarballPrefix}''${latestVer}${tarballSuffix}"
latestSha256="$(nix-prefetch-url --type sha256 "$artifactUrl")"
latestHash="$(nix-hash --to-sri --type sha256 "$latestSha256")"
# Update the selected variant in version.json
tmp="$(mktemp)"
jq \
--arg v "$variantEff" \
--arg latestBase "$latestBase" \
--arg latestRelease "$latestRelease" \
--arg latestHash "$latestHash" \
'
.variants[$v].variables.base = $latestBase
| .variants[$v].variables.release = $latestRelease
| .variants[$v].sources.proton.hash = $latestHash
' "$versionFile" > "$tmp"
mv "$tmp" "$versionFile"
git -C "$repoRoot" add "packages/proton-cachyos/version.json"
git -C "$repoRoot" commit -m "${repo}(${variantEff}): ''${localBase}.''${localRelease} -> ''${latestBase}.''${latestRelease}"
''

View File

@@ -2,7 +2,6 @@
lib,
bc,
bison,
fetchurl,
flex,
gnutls,
installShellFiles,

View File

@@ -1,4 +1,4 @@
{ pkgs, namespace, lib, ... }:
{ pkgs, namespace, ... }:
let
kernel = pkgs.${namespace}.linuxPackages_cachyos-deckify-lto;
in