cargoxx-pkgs registry skeleton

Empty package registry for cargoxx. flake.nix walks
recipes/<name>/versions/*.toml, exposes each (name, version) as
packages.<system>.{<name>_<safe_ver>, <name>}, and builds via
cargoxx.lib.${system}.buildCppPackage with pkgs.fetchgit.

.gitea/workflows/validate-pr.yml validates schema, refetches and verifies
source sha256, smoke-builds, pushes $out to the binary cache, and labels
auto-merge once the PR author is in maintainers.txt.

.gitea/workflows/auto-merge.yml merges via tea on the auto-merge label.
This commit is contained in:
2026-05-17 19:39:11 +00:00
commit f8a041f5b7
6 changed files with 289 additions and 0 deletions

88
flake.nix Normal file
View File

@@ -0,0 +1,88 @@
{
description = "cargoxx package registry";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
# During local development we point at the sibling cargoxx checkout
# via an absolute `git+file://` URL. Once the registry lives on Gitea
# this becomes a Gitea URL pinned to a specific cargoxx revision —
# that pin, alongside `lock.cargoxx_rev` in each recipe, is what
# makes registry derivations deterministic across consumers (see
# docs/library-reuse-and-publish.md in the cargoxx repo).
cargoxx.url = "git+file:///home/mozart/cargoxx";
};
outputs = { self, nixpkgs, flake-utils, cargoxx }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
# version_safe: 1.2.3 → "1_2_3". The attr name `<pkg>_<safe>` is
# the canonical handle for a (name, version) pair; bare `<pkg>`
# aliases the highest-versioned entry.
sanitizeVersion = v:
builtins.replaceStrings ["." "-" "+"] ["_" "_" "_"] v;
# Read recipes/<name>/versions/<v>.toml → buildCppPackage'd drv.
mkPackage = recipeFile:
let r = builtins.fromTOML (builtins.readFile recipeFile);
in cargoxx.lib.${system}.buildCppPackage {
src = pkgs.fetchgit {
inherit (r.source) url;
rev = r.source.commit;
hash = r.source.sha256;
};
name = "${r.name}-${r.version}";
};
# builtins.readDir → attrset of name → type ("regular"/"directory").
# Yields [{ name, type }] entries, filtering on a predicate.
dirEntries = path: predicate:
if builtins.pathExists path
then pkgs.lib.filterAttrs (n: t: predicate n t) (builtins.readDir path)
else {};
# All package directories under recipes/.
packageNames = builtins.attrNames
(dirEntries ./recipes (_: t: t == "directory"));
# For one package: enumerate its versions, returning an attrset
# { "<pkg>_<safe>" = <drv>; "<pkg>" = <highest-version drv>; }.
versionsFor = pkgName:
let
versionsDir = ./recipes + "/${pkgName}/versions";
files = builtins.attrNames
(dirEntries versionsDir (n: t:
t == "regular" && pkgs.lib.hasSuffix ".toml" n));
versions = map (f:
let
version = pkgs.lib.removeSuffix ".toml" f;
attr = "${pkgName}_${sanitizeVersion version}";
drv = mkPackage (versionsDir + "/${f}");
in { inherit version attr drv; }
) files;
byVersion = pkgs.lib.listToAttrs
(map (v: { name = v.attr; value = v.drv; }) versions);
highest = pkgs.lib.last
(pkgs.lib.sort (a: b:
builtins.compareVersions a.version b.version < 0) versions);
latestAlias =
if versions == [] then {}
else { ${pkgName} = highest.drv; };
in byVersion // latestAlias;
packagesAttrs = pkgs.lib.foldl' (acc: n:
acc // (versionsFor n)) {} packageNames;
in {
packages = packagesAttrs;
# Bare `nix flake check` should pass with zero recipes.
checks = {
schema-ok = pkgs.runCommand "registry-schema-ok" {} ''
touch $out
'';
};
});
}