Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib.fixedPoints.toExtension: init #336414

Merged
merged 6 commits into from
Sep 16, 2024
Merged

Conversation

ShamrockLee
Copy link
Contributor

Description of changes

This function is taken from stdenv.mkDerivation's implementation of overrideAttrs, and acts as a toFunction analogy for overlays.

Some packages/package sets have an argument in their override interface to take override functions, which might be anything from a plain attribute set to an overlay. To use the override interface while keeping the previous overriding, one would extend it with lib.composeExtensions, which only accepts overlays.

#225051 locally uses a function like this to convert the overrideModAttrs argument to passthru.overrideModAttrs. The former could be anything to pass to .overrideAttrs, but the latter must be an attribute overlay so that people could override with lib.composeExtension.

Other potential use cases include enabling custom overriders such as overridePythonAttrs support overlay-style overriding (drv.overridePythonAttrs (finalAttrs: previousPythonAttrs: { ... })), but that is out of the scope of this PR.

Things done

  • Built on platform(s)
    • x86_64-linux (no rebuild)
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: stdenv Standard environment 6.topic: lib The Nixpkgs function library labels Aug 21, 2024
@ShamrockLee
Copy link
Contributor Author

Result of nixpkgs-review run on x86_64-linux 1

1 package blacklisted:
  • nixos-install-tools
2 packages built:
  • disko
  • nixpkgs-manual

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Aug 21, 2024
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!

lib/fixed-points.nix Outdated Show resolved Hide resolved
lib/fixed-points.nix Outdated Show resolved Hide resolved
pkgs/stdenv/generic/make-derivation.nix Outdated Show resolved Hide resolved
@ShamrockLee ShamrockLee force-pushed the lib-to-extension branch 2 times, most recently from f1cbf18 to 6d85173 Compare August 23, 2024 00:34
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a few suggestions for the docs, but otherwise LGTM!

lib/fixed-points.nix Outdated Show resolved Hide resolved
lib/fixed-points.nix Outdated Show resolved Hide resolved
lib/fixed-points.nix Outdated Show resolved Hide resolved
lib/fixed-points.nix Outdated Show resolved Hide resolved
lib/fixed-points.nix Outdated Show resolved Hide resolved
lib/fixed-points.nix Outdated Show resolved Hide resolved
lib/fixed-points.nix Outdated Show resolved Hide resolved
ShamrockLee and others added 6 commits September 14, 2024 20:54
Co-authored-by: Robert Hensing <[email protected]>
This makes the type more informative and general - closer to how the function behaves, particularly in isolation.

Co-authored-by: Yueh-Shun Li <[email protected]>
Use toExtension from Nixpkgs library instead of the one defined locally.
@doronbehar
Copy link
Contributor

Thanks for this PR, it is a little bit above my league and above my current level of available focus to review it properly, but it looks good and useful. Do you think it'd be possible to use these changes to help with #44426 ?

@roberth roberth merged commit 20f9370 into NixOS:master Sep 16, 2024
23 checks passed
@roberth
Copy link
Member

roberth commented Sep 16, 2024

Thank you @ShamrockLee!

@doronbehar Yes, it seems like a useful function for that, especially if it needs to support both the arity-1 and arity-2 style overriding like overrideAttrs does. After calling this, you always have overlays, and you can work with the functions for overlays to handle them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: golang 6.topic: lib The Nixpkgs function library 6.topic: stdenv Standard environment 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants