lib.mkPackageVariants: init; openssl: migrate to mkPackageVariants#496617
lib.mkPackageVariants: init; openssl: migrate to mkPackageVariants#496617qweered wants to merge 5 commits intoNixOS:masterfrom
Conversation
96ec04d to
6653d83
Compare
RossComputerGuy
left a comment
There was a problem hiding this comment.
The approach so far seems reasonable, only have this nit so far.
|
b3c1085 to
912f142
Compare
| pkg.overrideAttrs (o: { | ||
| passthru = | ||
| o.passthru or { } | ||
| // mkVariantPassthru variantArgs | ||
| // { | ||
| inherit variantArgs; | ||
| }; | ||
| }); |
There was a problem hiding this comment.
How do we tell the nixpkgs search which attributes should be shown?
How do we tell hydra where all the package variants are located that need to be evaluated?
As far as I know this is currently done through recurseForDerivations = true;, so all attribute sets with that attribute are also searched for derivations.
This does not work for attributes in passthru. We can't search every package for derivations.
There was a problem hiding this comment.
Yeah, derivations inside derivations are a non‐starter without several changes outside of Nixpkgs. nix search and nix-env can’t handle them either; it’s baked into the codebase.
There was a problem hiding this comment.
While writing down the new version of my RFC 197 I thought we could maybe make all versioned packages package sets like we currently do for nix with nixVersions.
If we do that it would be consistent to also have versioned package sets be in a package-set-set like currently for ocamlPackages with ocaml-ng and lixPackages with lixPackageSets.
Add `lib.mkPackageVariants`, a utility for managing multiple variants (versions or feature variants) of a single package with a shared generic builder. The function is curried in three stages: 1. Scope args (callPackage, allowAliases) — pre-bound in splice.nix 2. Override args — captured via @Args, forwarded to the generic builder 3. Package config — variant selection, paths, aliases The generic builder follows a curried pattern: variantArgs -> packageArgs -> derivation-attrs Each variant's passthru includes references to all other variants, enabling access patterns like `pkg.v1_1`, `pkg.v3`, etc.
Preparatory rename for the mkPackageVariants migration to preserve git history
912f142 to
cbd10b6
Compare
cbd10b6 to
bf731f2
Compare
Refactor openssl to use the new `lib.mkPackageVariants` utility: - generic.nix: Convert from monolithic callPackages pattern to curried builder (variantArgs -> packageArgs -> derivation-attrs). Replace lib.versionOlder/AtLeast with injected packageOlder/packageAtLeast. Move withDocs and extraMeta logic into the builder using version checks instead of per-variant metadata. - variants.nix: Extract version metadata (version, hash, patches) into a dedicated file resolved via callPackage. - default.nix: Thin mkPackageVariants entry point that only specifies the default variant selector. - all-packages.nix: Simplify openssl wiring. Old names (openssl_1_1, openssl_3, openssl_3_6) become aliases to openssl.v1_1 etc.
Move openssl from pkgs/development/libraries/openssl to pkgs/by-name/op/openssl, renaming default.nix to package.nix per by-name convention.
bf731f2 to
db6f0b0
Compare
Adds
lib.mkPackageVariantsto standardize multi-version package management in nixpkgs. Currently, packages like openssl, perl, etc. each reinvent their own variant handling — this provides a shared abstraction for it. Extensive tests added to lib/test/customisation.nixInspired by corepkgs'
mkManyVariants, but adapted for nixpkgs:mkManyVariantsmkPackageVariantscallPackagecallFromScopecallPackage, pre-bound viasplice.nix(same pattern ascallPackageitself)allowAliasesconfigdirectlyconfig.allowAliasesin the splice bindingdefaultPackage.overridedefaultPackagedirectly (override is already available viacallPackage/makeOverridable)overrideArgsallows feature variants (e.g.,oqs,legacy) that share version metadata but change build argumentsvariants.nixandgeneric.nixin caller's directory viaunsafeGetAttrPosThe generic builder follows a curried pattern — first receives variant-specific args (version, hash, patches, plus helpers like
packageOlder/packageAtLeast), then package args resolved bycallPackage. All variants are accessible via passthru (e.g.,openssl.v1_1,openssl.v3_6,openssl.oqs), andpkg.override { ... }flows through to the generic builder without per-package boilerplate.I migrated openssl as a proof-of-concept to verify everything works end-to-end, including by-name compatibility. The old monolithic
default.nixis split intogeneric.nix(curried builder),variants.nix(version metadata), and a thinpackage.nixwrapper.openssl_oqsandopenssl_legacyare also migrated from inline.overridecalls to proper variants. All backward-compat aliases are preserved.Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.