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
a single version attribute for expressions previously using "majorVersion" #36168
Conversation
Success on x86_64-darwin (full log) Partial log (click to expand)
|
Success on x86_64-linux (full log) Partial log (click to expand)
|
Success on aarch64-linux (full log) Partial log (click to expand)
|
Success on x86_64-darwin (full log) Partial log (click to expand)
|
Success on aarch64-linux (full log) Partial log (click to expand)
|
Success on x86_64-linux (full log) Partial log (click to expand)
|
See also |
@jtojnar Cool, that's the same function. What do you think of this change? |
lib/strings.nix
Outdated
majorMinorVersion "1.2.3" | ||
=> "1.2" | ||
*/ | ||
majorMinorVersion = v: builtins.concatStringsSep "." (lib.lists.take 2 (splitString "." v)); |
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.
How about lib.semver.majorVersion
and lib.semver.minorVersion
or is this too verbose?
but maybe this also causes ambiguity.
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.
How about lib.semver.major
, lib.semver.minor
, lib.semver.majorMinor
?
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.
Is the name semver
common enough, that people will figure out the meaning on there own?
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.
But maybe this becomes clear when it is used in the code and the passed variable is called version
.
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.
It is not limited to semver – see the GNOME example.
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.
It seems like "major" and "minor" are pretty universally the first and second parts of a version, so how about we make lib.version.major
, lib.version.minor
, and lib.version.majorMinor
? We can also move lib.strings.versionOlder
, and lib.strings.versionAtLeast
into there as lib.version.older
and lib.version.atLeast
later.
I updated the code to match my latest proposal. |
Success on x86_64-darwin (full log) Partial log (click to expand)
|
Success on aarch64-linux (full log) Partial log (click to expand)
|
The problem with nested attributes is that it is not very idiomatic. |
Success on x86_64-linux (full log) Partial log (click to expand)
|
Thanks for pointing that out. I'll work on fixing it. |
We also have |
@ryantm Notice that now nix has a |
I vote |
Actually I also don't have strong preference, but without looking at the source code I would not figure out what |
|
Probably Edited: #34636 has just been merged. |
@GrahamcOfBorg eval |
Updated to use |
Success on x86_64-darwin (full log) Partial log (click to expand)
|
Success on x86_64-linux (full log) Partial log (click to expand)
|
Success on aarch64-linux (full log) Partial log (click to expand)
|
Thanks! |
Many packages in nixpkgs split the version string into a "major" and "minor" part because the upstream source distribution URL is something like "/project/2.3/projectname-2.3.4.tar.gz". This PR introduces a new function
majorMinorVersion
that lets us declare the version with a single attribute, allowing for easier expression updating via tooling.Say the package is at version "1.2.3", the expressions currently use the terminology
majorVersion
to mean "1.2", andminorVersion
to mean "3". I chose to use the Semantic Versioning terminology in this function, which meansmajorMinorVersion
refers to "1.2" ("3" would be the "patch" part of the version, but isn't relevant to this). I don't care too much about the name, though I did think about it carefully, so if someone some other preference that's fine.This PR includes an example usage of
majorMinorVersion
in the haproxy package.