Skip to content

About

Nix packages providing patched versions of repos on this org

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

auto-patcher/nur-packages

A NUR (Nix User Repository) package set for the auto-patcher org. Package definitions are generated automatically by an external auto-patcher, one derivation per <package> <version>.

Packages are named <pkg>_<major>_<minor> (e.g. foo_1_2) and live in a flat namespace. Consumers reach them as nur.repos.auto-patcher.<pkg>_<major>_<minor>.

Binary cache

Build results are pushed to the public Cachix cache auto-patcher by CI, so consumers fetch binaries instead of rebuilding from source (NUR is evaluated by the community infra but not built by Hydra). Add it as a substituter:

nix.settings = {
  substituters = [ "https://auto-patcher.cachix.org" ];
  trusted-public-keys = [ "auto-patcher.cachix.org-1:<public-key-from-app.cachix.org>" ];
};

or ad hoc: cachix use auto-patcher. The public key is shown on the cache page.

Consuming

Via the NUR overlay

Once this repo is registered with NUR, add NUR as usual and reference packages by their flat name:

{ pkgs ? import <nixpkgs> { } }:

let
  nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/main.tar.gz") {
    inherit pkgs;
  };
in
nur.repos.auto-patcher.foo_1_2

Or wire it in as an overlay / packageOverrides per the NUR installation docs.

As a direct flake input (no NUR)

This repo is a self-contained flake, so you can depend on it directly without pulling in NUR:

{
  inputs.auto-patcher.url = "github:auto-patcher/nur-packages";

  outputs = { self, nixpkgs, auto-patcher }: {
    # the package set for your system
    # auto-patcher.packages.${system}.foo_1_2

    # or merge everything into nixpkgs via the overlay
    # nixpkgs.legacyPackages.${system} extended with auto-patcher.overlays.default
  };
}

Flake outputs:

  • packages.<system>.<pkg>_<major>_<minor> — each package as a derivation.
  • packages.<system>.default — builds the entire set at once.
  • overlays.default — merges the package set into an existing nixpkgs.
  • legacyPackages.<system> — mirrors default.nix (the NUR evaluation entry point).

Layout

default.nix                       # flat namespace consumers see (GENERATED — do not hand-edit)
flake.nix                         # flake wrapper: packages / overlay / legacyPackages
pkgs/<name>/build.nix             # version-agnostic recipe (written once, never overwritten)
pkgs/<name>/<major>_<minor>.nix   # generated thin file: version + rev + hash
pkgs/auto-packager/                  # "meta" package: the generator, built with nix
tools/auto-packager/{go.mod,*.go,…}  # the generator's Go source

Every package sets meta (description + license, optionally platforms) so it is indexed by NUR search. Packages that cannot build are kept with meta.broken = true rather than deleted.

Meta packages

The NUR's own tooling is itself packaged and exposed in the namespace as a "meta" package, so it is built and verified by CI like everything else:

  • auto-packager — the generator (nur.repos.auto-patcher.auto-packager, nix run .#auto-packager). Source: tools/auto-packager/, built by pkgs/auto-packager/default.nix via buildGoModule.

Meta packages are declared in a small static list in the generator (metaPackages in tools/auto-packager/generate.go); everything else in default.nix is discovered by scanning pkgs/.

Auto-patcher pipeline

Packages are generated and updated by auto-packager, a small Go program that renders Nix from text/template — no LLM in the update loop. There are two entry points and two ways they fire.

The generator (auto-packager)

nix run .#auto-packager -- set --repo <name> --tag <tag>   # one package
nix run .#auto-packager -- sync-all                        # every org repo -> latest tag
nix run .#auto-packager -- regen                           # re-derive default.nix from pkgs/

# or, from source:  cd tools/auto-packager && go run . <cmd>

set parses the tag (v1.2.3 → 1.2.3, major 1, minor 2), prefetches the source hash with nix-prefetch-url --unpack, and renders the version file from a Go template. sync-all walks every repo in the org (via gh), resolves each one's latest numeric tag, and updates them all. Both are idempotent.

default.nix is fully generated by scanning pkgs/ — the filesystem is the source of truth. After writing version files, the generator re-renders default.nix from the discovered <major>_<minor>.nix files plus the static meta packages, sorted. Don't hand-edit default.nix; run regen instead.

Each package owns a version-agnostic recipe at pkgs/<name>/build.nix, written once when the repo is onboarded and never overwritten by the generator. The generator only writes the thin, per-version pkgs/<name>/<major>_<minor>.nix (which passes version + rev + hash into build.nix). Customize a package's real build by editing its build.nix; the default template is a passthrough that installs the source.

How it fires

  • On a new tag (event-driven). A source repo adds the init template templates/source-repo/on-tag.yml (→ its .github/workflows/on-tag.yml). On every tag push it calls this repo's reusable notify-nur.yml, which sends a package-tagged repository_dispatch to nur-packages. That triggers update.yml here, which regenerates the package, verifies it builds, and commits to the default branch.
  • On a schedule (reconcile). sync.yml runs sync-all daily (and on demand) to catch anything a dispatch missed.
source repo (tag push)
  └─ on-tag.yml ──uses──▶ nur-packages/notify-nur.yml ──dispatch──▶ nur-packages/update.yml
                                                                      └─ auto-packager set → build → commit
nur-packages/sync.yml (cron) ─────────────────────────────────────▶ auto-packager sync-all → build → commit

Onboarding a repo

  1. Add templates/source-repo/on-tag.yml to the repo as .github/workflows/on-tag.yml.
  2. Ensure the org AUTO_PATCHER_APP_ID variable and AUTO_PATCHER_APP_KEY secret (the GitHub App credentials) are available to it, and that nur-packages allows its reusable workflows to be called by org repos. The workflow mints a short-lived App token at runtime — no long-lived secret in the repo.
  3. Tag a release — or run the sync all / update package workflow here manually with the repo + tag. The first run creates pkgs/<name>/build.nix; edit it to add the real build and license.

Naming & default.nix contract

  • Attribute names are flat: <pkg>_<major>_<minor> (e.g. foo_1_2). Meta packages keep their plain name (e.g. auto-packager).
  • A version's derivation lives at pkgs/<pkg>/<major>_<minor>.nix and is a callPackage-style function. The generator writes it from a template as a thin wrapper that calls pkgs/<pkg>/build.nix with version/rev/hash.
  • default.nix is generated, not hand-written: it is the sorted union of the static meta packages and every <major>_<minor>.nix discovered under pkgs/, each emitted as attr = pkgs.callPackage <path> { };. Add/remove a version file (or run set/sync-all) and re-run regen to update it.
  • Always set meta.description and meta.license. Mark unbuildable packages meta.broken = true instead of removing them.

Until source repos are onboarded, the only entry is the auto-packager meta package; the auto-patched packages appear here as repos get tagged.

About

Nix packages providing patched versions of repos on this org

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages