lib.systems: deprecate == comparison between elaborated platforms#380005
lib.systems: deprecate == comparison between elaborated platforms#380005MattSturgeon wants to merge 6 commits intoNixOS:masterfrom
== comparison between elaborated platforms#380005Conversation
9207755 to
903c2b8
Compare
c12ddc8 to
e105d83
Compare
roberth
left a comment
There was a problem hiding this comment.
My thoughts. I'm not the most knowledgeable person on the subject of these platform values, but I'd like to support you and @wolfgangwalther if possible.
e105d83 to
d005e0b
Compare
FliegendeWurst
left a comment
There was a problem hiding this comment.
Another merge conflict appeared. LGTM otherwise.
doc/release-notes/rl-2505.section.md
Outdated
There was a problem hiding this comment.
Not sure why the example replacement is replacing equals with canExecute.
There was a problem hiding this comment.
It's one possible replacement for some cases, because often enough the == check is just trying to prevent "real cross" scenarios, where you can't execute the binaries on your build system. So for a lot of cases, this could be a better replacement, but it might not always be correct.
There was a problem hiding this comment.
I know of many packages where the build system just doesn't understand the distinction between build and host. For such cases an equality check makes sense.
|
To move this PR forward, I'd like to focus on the one thing that should be discussed most:
Previously, the plan has been to get rid of all functions in elaborated platforms to eventually support Are there any objections to this? If not, I think we should ship the deprecation with 25.05. I would not consider the deprecation itself a breaking change, so I don't think we are bound to the 23rd as a date. Please voice your concerns, if any, until next Friday, the 25th of April. |
|
Sorry for taking so long to get around to this. My tl;dr take:
|
I for one value your input! ❤️
Agreed. It's also worth noting that
Yes, it's sad that we can't find a reliable way to print a warning on
This would be possible with a
That would also require the same #380342 is attempting to do something similar by capturing inputs in the
👍 |
28e5cf4 to
bc90e2e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
bc90e2e to
06b7740
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Allows replacing `lib.systems.equals foo bar` with `foo.equals bar`. This is useful when `lib` isn't readily available, and is often less verbose.
In preparation for deprecating `==` usage on platform attrs.
`(elaborated platform) == "string"` will always be false. This was probably intended as `(elaborated platform).system == "string"`. That said, this should usually be replaced with checking the relevant boolean attributes, such as `isLinux` or `isDarwin`.
Added `warnAboutPlatformEquals` to elaborated platforms. This new attr prints a warning when evaluated. This is intended to detect `==` comparison being used with platform attrsets. This isn't perfect, because it is only evaluated if the `==` comparison has not already short-circuited. E.g. if the attr-count is different or some other difference has already been found before getting to the `warnAboutPlatformEquals` attr. Added a "backwards compatibility" item to the release notes. Co-authored-by: Robert Hensing <[email protected]>
A `removeAttrs` call was added by 4eca30d We may as well use it to simplify the test's implementation.
06b7740 to
c0509c5
Compare
(FWIW, explicitly not mixing them was my intention – it makes sense to me to separate inputs and computed values, because that is exactly what lets you compute new values from a modified input. However I realize that would be a considerably bigger change to disentangle all this stuff.) |
It would. I'm still exploring the idea lately, thus I haven't acted here, yet. |
As suggested by @wolfgangwalther #380005 (comment), I've scaled back this PR to focus on the treewide deprecation of
==comparison between elaborated platform attrsets. The other changes are replaced by #380342.This is in contrast to the previous effort to fully support
==with elaborated platform attrsets: #238331. Also related: #278001.A "backwards compatibility" item has been added to the release notes.
Added
equalsandnotEqualsfunctions to elaborated systems. This makes replacing==and!=usage simpler, and also provides a convenient alternative to usinglib.systems.equalsdirectly.Added an extra attr (
warnAboutEquality) to elaborated systems that exists only to produce a warning when evaluated. This is intended to detect==comparison being used with platform attrsets, suggested by @roberth #380005 (comment).This approach isn't perfect, because it is only evaluated if the
==comparison has not already short-circuited. E.g. if the attr-count is different or some other difference has already been found before getting to thewarnAboutEqualityattr. These limitations were raised by @wolfgangwalther #380005 (comment) and were also discussed in this note.The treewide change has been done using some regex search/replace together with vim's quickfix list and some manual checking. It covers ~600 changes, so I haven't been able to check each individual replacement in detail. As mentioned by @roberth, many of the replacements could probably use
canExecinstead ofequals, but that change is not in scope for this PR.Old summary
Intended to enable composition of package sets by preserving the original un-elaborated arguments passed to
lib.systems.elaborate.This PR does not actually make package sets composable, but it is intended that the implementation proposed here will enable @wolfgangwalther to revisit their earlier work in #303849 and #376988 without needing to make changes to the public API or the
nixpkgsnixos module.Adds:
lib.systems.isElaborated_typetag for elaborated systemsinputattr on elaborated systemslib.systems.equalsignores the newinputattrAdditionally:
equalsandnotEquals"method" attr-functions for convenience, and to allow comparison without needing access tolib==-><platform>.equals==cc @wolfgangwalther @roberth
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-build ./lib/tests/release.nix --abort-on-warn --show-tracenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.