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

binlore: migrate override lore to package passthru #311811

Merged

Conversation

abathur
Copy link
Member

@abathur abathur commented May 15, 2024

Move lore overrides from binlore's source repo to the passthru of the target packages.

Note: to keep this from sprawling, see issue/previous PR below for more background/explanation:

Description of changes

  • Change how lore is merged/gathered:

    • Don't apply overrides from binlore's source.

    • Merge lore from $out/nix-support/<loretype> if it exists. Prepares binlore to collect lore generated by makeWrapper and friends.

      (Saving that for a follow-up, since it's a huge rebuild that makes this harder to test.)

    • Merge lore from <package>.binlore if it exists.

      (Happy to debate this name. Avoiding overrideLore since override is roughly a contract in nixpkgs.)

      Note: this has been changed from <package>.lore to <package>.binlore during review in order to mitigate confusion about what this is for. We might need to revisit this later if there are more lore providers (or we come up with better terms all around).

  • Add a utility function (binlore.synthesize) for ~synthesizing lore overrides. It rolls in a small Shell DSL for efficiently expressing overrides.

    (Happy to debate this name. Avoiding override since it's roughly a contract in nixpkgs.)

  • Reimplement most overrides using passthru.binlore = binlore.synthesize ...;. (I'm skipping some to pare them back to the set needed for nixpkgs and other public repos found via search.)

  • Expand resholve's passthru tests to better exercise the machinery.

I also have a branch with these changes based on a recent nixpkgs-unstable commit for easier testing. I generally test with nix-build -A resholve.tests.

Things done

  • Built on platform(s)
    • x86_64-linux
    • 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.05 Release Notes (or backporting 23.05 and 23.11 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.

@abathur
Copy link
Member Author

abathur commented May 15, 2024

@ofborg build resholve.tests

@abathur abathur requested review from K900 and roberth May 16, 2024 14:43
@abathur abathur force-pushed the move_lore_overrides_to_passthru_staging branch from 39250a3 to 5f51680 Compare May 18, 2024 21:02
@abathur
Copy link
Member Author

abathur commented May 18, 2024

@ofborg build resholve.tests

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.

Raised minor concerns about documentation out-of-band; which @abathur will handle with infinisil / docs team, and async from this because staging PRs aren't particularly suited for iterating on docs and such.

pkgs/by-name/pd/pdf2odt/package.nix Show resolved Hide resolved
@@ -125,4 +128,11 @@ stdenv.mkDerivation (finalAttrs: {
passthru.tests = {
inherit cmake nix samba;
};

# bsdtar is detected as "cannot" because its exec is internal to
Copy link
Member

Choose a reason for hiding this comment

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

Maybe move the comment inside so that it is closer when another lore items are added.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this on the right one? I'm not sure about moving it into the multiline string. I do like moving it closer, but I think I prefer the clearer legibility of it being a comment at the Nix level.

If we need to leave breadcrumbs for more executables, the comments can just be converted into a bulleted list?

pkgs/os-specific/linux/procps-ng/default.nix Outdated Show resolved Hide resolved
pkgs/tools/text/esh/default.nix Show resolved Hide resolved
@@ -30,7 +30,9 @@ let
priority = 10;
platforms = platforms.${stdenv.hostPlatform.parsed.kernel.name} or platforms.all;
};
passthru = { inherit provider; };
passthru = { inherit provider; } // lib.optionalAttrs (builtins.hasAttr "binlore" providers) {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how compatible the different providers are. I can imagine GNU adding some extra flags. But we can probably handle that if this becomes a problem.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, it might make some sense to inherit lore from the individual provider packages.

Copy link
Member Author

Choose a reason for hiding this comment

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

If by this you mean push them out into the packages where these all come from, I think I mostly agree.

I tried that first and ended up settling with implementing them here for a few expedience reasons, the foremost of which was not really being able to figure out how to splice it in to some of the macOS commands which are already fairly abstractly sliced out of source releases in a way that makes it hard to tell where and how to intervene and also be able to pair up lore overrides for the commands we care about.

Looking around at the implementation of diskdev_cmds in https://github.com/NixOS/nixpkgs/tree/master/pkgs/os-specific/darwin/apple-source-releases may clarify why I backed off of that (but I'm happy to do it if you can tell how we could accomplish it in a way that's as or more straightforward than what I have now?)

pkgs/tools/misc/coreutils/default.nix Show resolved Hide resolved
''
for lore_type in ${builtins.toString lore.types}; do
if [[ -f "${drv}/nix-support/$lore_type" ]]; then
cat "${drv}/nix-support/$lore_type" >> "$out/$lore_type"
Copy link
Member

Choose a reason for hiding this comment

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

Having two different directory paths is weird. Would it be feasible to standardize on e.g. lib/binlore/$lore_type?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've waffled a little about where to put this.

Open to changing it (whether here or later) so I'll just think out loud for now:

  • I think if we moved it into a lib/ dir it'd be at risk of getting split off into a lib output when it's present (so I guess this is at least somewhat related to your other question about multiple outputs)?
  • When I was first thinking about doing this I didn't feel like it was my place to take up part of the nix-support namespace and imagined this actually belongs in some new namespace that doesn't imply it's just for nix/nixpkgs internal purposes. I opened an issue in the architecture repo last year but it didn't go anywhere and has been since transferred into this repo (Attaching more kinds of data to packages? #295029).
  • In make(Binary)Wrapper: record created wrappers #314937 I'm also tweaking the wrapper generators to output this data, and nix-support/ does feel more semantically appropriate from that perspective. Since this path is ~anticipating the other change, maybe it feels less out-of-place with that in frame?

pkgs/development/tools/analysis/binlore/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/analysis/binlore/default.nix Outdated Show resolved Hide resolved
@abathur
Copy link
Member Author

abathur commented Jun 28, 2024

@ofborg build resholve.tests

@thiagokokada
Copy link
Contributor

thiagokokada commented Jul 3, 2024

Looks good to me, but please fix the commit messages and rebase.

Lore overrides have been included with binlore's source up to now, but
this hasn't worked very well. (It isn't as easy to self-service for
people working in nixpkgs, and its use of partial pnames for matching
breaks down around some edge cases like version numbers appearing
early in perl pnames, or multiple packages having identical pnames.)
@abathur abathur force-pushed the move_lore_overrides_to_passthru_staging branch from a48c633 to 8f413d8 Compare July 4, 2024 16:15
@thiagokokada
Copy link
Contributor

Eval error.

@abathur
Copy link
Member Author

abathur commented Jul 4, 2024

Sounds like the problem this one's addressing:

@thiagokokada
Copy link
Contributor

@ofborg eval

1 similar comment
@thiagokokada
Copy link
Contributor

@ofborg eval

@thiagokokada
Copy link
Contributor

Eval is still failing. Maybe you need to rebase?

@abathur
Copy link
Member Author

abathur commented Jul 5, 2024

It looks like the periodic merges into staging have been failing, so I think it isn't in staging yet: https://github.com/NixOS/nixpkgs/actions/workflows/periodic-merge-6h.yml

@abathur
Copy link
Member Author

abathur commented Jul 6, 2024

@ofborg eval

@thiagokokada thiagokokada merged commit c62ade3 into NixOS:staging Jul 9, 2024
22 checks passed
@abathur abathur deleted the move_lore_overrides_to_passthru_staging branch July 13, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants