-
Notifications
You must be signed in to change notification settings - Fork 84
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
Allow arbitrary expressions in attribute_path. #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests fail. Needs a unit test.
nixpkgs/nixpkgs.bzl
Outdated
# example of this is haskellPackages.ghcWithPackages which is | ||
# unusable with -A. | ||
res = ctx.execute(["nix-build", path, "-E", | ||
"(import <nixpkgs> {{}}).{0}".format(attr_path), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if an attribute path is now really an expression, then the name should be changed and it should be documented.
??? |
9763046
to
e908785
Compare
I changed the implementation a bit to allow arbitrary expressions and added a couple of tests. I hope they pass now. |
Hm, I think nix 1.12 is needed for |
The oracle here is CircleCI. Green on master but red on this branch. Can't merge until this one goes green. |
e908785
to
ff76eb1
Compare
Turned out to be dumb mistake, should be green, PATAL. |
nixpkgs/nixpkgs.bzl
Outdated
"""Generate a nix expression that picks a package from nixpkgs. | ||
""" | ||
if ctx.attr.attribute and ctx.attr.expression: | ||
fail("'attribute' and 'expression' are mutually exclusive.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the two should be mutually exclusive. -A
and -E
are not mutually exclusive flags to nix-build
. When used together, -E e -A some.path
means e.some.path
. We should reproduce the same semantics here.
This allows us to be much more flexible when we want to be while maintaining convenience for simple attribute cases.
ff76eb1
to
25f8361
Compare
Addressed. Didn't realise you could combine -E and -A. |
We really are passing an attribute *path*, not a Nix attribute. The Nix documentation defines an attribute path as a dot separated sequence of attributes.
Note: for now we're documenting attributes in README, not using inline docstrings. |
Move custom code out of nixpkgs subfolder. Wrap nix_cc with macro to use supports_nix constraint.
This allows more advanced attributes to be used. Motivating use-case
is ghcWithPackages.