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

feat: add --apply flag #332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ysndr
Copy link

@ysndr ysndr commented Oct 16, 2024

Allow applying every eval'ed drv to a provided nix expression to evaluate arbitrary fields.

EXAMPLE

% ./result/bin/nix-eval-jobs --flake github:NixOS/patchelf#hydraJobs \
  --apply \
  'drv: {
     version = if drv ? version then drv.version else null;
   }'
warning: `--gc-roots-dir' not specified
{"attr":"coverage","attrPath":["coverage"],"version":null}
{"attr":"patchelf-win32","attrPath":["patchelf-win32"],"version":"0.18.0"}
{"attr":"patchelf-win64","attrPath":["patchelf-win64"],"version":"0.18.0"}
{"attr":"release","attrPath":["release"],"version":null}
{"attr":"tarball","attrPath":["tarball"],"version":"0.18.0"}

@Mic92
Copy link
Member

Mic92 commented Nov 6, 2024

@mergify rebase

Copy link
Contributor

mergify bot commented Nov 6, 2024

rebase

✅ Branch has been successfully rebased

@Mic92
Copy link
Member

Mic92 commented Nov 6, 2024

That crash looks legit. Do you have issues reproducing this locally?

@ysndr
Copy link
Author

ysndr commented Nov 7, 2024

I don't remember that failing
Will have a look later

Allow applying every eval'ed drv to a provided nix expression to evaluate arbitrary fields.

EXAMPLE

```
% ./result/bin/nix-eval-jobs --flake github:NixOS/patchelf#hydraJobs \
  --apply \
  'drv: {
     version = if drv ? version then drv.version else null;
   }'
warning: `--gc-roots-dir' not specified
{"attr":"coverage","attrPath":["coverage"],"version":null}
{"attr":"patchelf-win32","attrPath":["patchelf-win32"],"version":"0.18.0"}
{"attr":"patchelf-win64","attrPath":["patchelf-win64"],"version":"0.18.0"}
{"attr":"release","attrPath":["release"],"version":null}
{"attr":"tarball","attrPath":["tarball"],"version":"0.18.0"}
```
@ysndr
Copy link
Author

ysndr commented Jan 15, 2025

Sorry for letting this sit so long!

I've rebased the PR onto main again and fixed the test.
I saw that this shares a branch with the new "constituents" evaluation,
I'm not sure whether those ought to be mutually exclusive or not (currently it seems possible to give both --constituents and --apply but only the first will be used, though i think we could collect constituents and user defined fields at without too much (precedence?).

@ysndr ysndr marked this pull request as ready for review January 15, 2025 17:36
@@ -203,6 +205,26 @@ void worker(
}
maybeConstituents =
Constituents(constituents, namedConstituents);
} else if (args.applyExpr != "") {
Copy link
Member

Choose a reason for hiding this comment

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

Do we only run apply if it's not a derivation? Why not always do that?

Copy link
Member

Choose a reason for hiding this comment

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

Ah. this is about constituents

Copy link
Member

Choose a reason for hiding this comment

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

@Ma27 do we want to have apply also working if we do have constituents?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any reason against it.

Copy link
Author

Choose a reason for hiding this comment

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

I have no issue with having it aside of constituents, what do you think should the precedence be?
i.e. if --apply produces a constituents attribute, should that be overridden by constituents, or should we side step that question and put the result of apply into a separate attribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants