lib/nix: use locked nixpkgs for maintainer extraction

Importing <nixpkgs> tied extraction to the caller's NIX_PATH. When that
channel lacks a maintainer referenced through `with lib.maintainers`
(such as sherlock's `_74k1`, which exists in the locked nixpkgs but not
in an older channel), evaluation fails outright and the generated list
varies by machine. Resolve nixpkgs from flake.lock so extraction matches
what Home Manager builds with.

Also classify maintainers by identity (github/name) rather than attribute
name so renamed entries like `_9p4` still match, and correct the
arguments passed to the manual derivation so its maintainer is collected.
This commit is contained in:
Austin Horstman
2026-06-29 11:12:43 -05:00
parent 9eec3ef087
commit 7042d2b31b
+35 -20
View File
@@ -1,7 +1,14 @@
# Extract maintainers from Home Manager modules using meta.maintainers # Extract maintainers from Home Manager modules using meta.maintainers
# This script evaluates all Home Manager modules and extracts the merged maintainer information # This script evaluates all Home Manager modules and extracts the merged maintainer information
let let
pkgs = import <nixpkgs> { }; flakeLock = builtins.fromJSON (builtins.readFile ../../flake.lock);
nixpkgsNodeName = flakeLock.nodes.root.inputs.nixpkgs;
nixpkgsLocked = flakeLock.nodes.${nixpkgsNodeName}.locked;
pkgs = import (fetchTarball {
url = "https://github.com/${nixpkgsLocked.owner}/${nixpkgsLocked.repo}/archive/${nixpkgsLocked.rev}.tar.gz";
sha256 = nixpkgsLocked.narHash;
}) { };
lib = import ../../modules/lib/stdlib-extended.nix pkgs.lib; lib = import ../../modules/lib/stdlib-extended.nix pkgs.lib;
releaseInfo = pkgs.lib.importJSON ../../release.json; releaseInfo = pkgs.lib.importJSON ../../release.json;
@@ -25,18 +32,23 @@ let
file: file:
let let
fileContent = import file; fileContent = import file;
# Arguments expected by docs/home-manager-manual.nix.
evaluated = evaluated =
if lib.isFunction fileContent then if lib.isFunction fileContent then
fileContent { fileContent {
inherit (pkgs) stdenv lib; inherit lib;
documentation-highlighter = { }; inherit (pkgs)
callPackage
mdbook
python3
stdenv
;
revision = "unknown"; revision = "unknown";
home-manager-options = { home-manager-options = {
home-manager = { }; home-manager = { };
nixos = { }; nixos = { };
nix-darwin = { }; nix-darwin = { };
}; };
nixos-render-docs = { };
} }
else else
fileContent; fileContent;
@@ -59,27 +71,30 @@ let
allMaintainerObjects = extractMaintainerObjects maintainers ++ additionalMaintainerObjects; allMaintainerObjects = extractMaintainerObjects maintainers ++ additionalMaintainerObjects;
allMaintainerNames = lib.filter (name: name != null) ( getMaintainerName = maintainer: maintainer.github or maintainer.name or null;
map (maintainer: maintainer.github or maintainer.name or null) allMaintainerObjects
); allMaintainerNames = lib.filter (name: name != null) (map getMaintainerName allMaintainerObjects);
hmMaintainers = import ../../modules/lib/maintainers.nix; hmMaintainers = import ../../modules/lib/maintainers.nix;
hmMaintainerNames = lib.attrNames hmMaintainers; hmMaintainerNames = lib.filter (name: name != null) (
map getMaintainerName (lib.attrValues hmMaintainers)
);
maintainerDetails = lib.pipe allMaintainerObjects [ maintainerDetails = lib.pipe allMaintainerObjects [
(lib.filter (obj: (obj.github or obj.name or null) != null)) (lib.filter (obj: (obj.github or obj.name or null) != null))
(map (obj: { (map (
name = obj.github or obj.name; obj:
value = obj // { let
source = maintainerName = obj.github or obj.name;
if categorizedMaintainers.home-manager ? ${obj.github} then in
"home-manager" {
else if categorizedMaintainers.nixpkgs ? ${obj.github} then name = maintainerName;
"nixpkgs" value = obj // {
else source =
throw "${obj.github} is neither a home-manager or nixpkgs maintainer"; if categorizedMaintainers.home-manager ? ${maintainerName} then "home-manager" else "nixpkgs";
}; };
})) }
))
lib.listToAttrs lib.listToAttrs
]; ];