diff options
author | Joachim F <joachifm@users.noreply.github.com> | 2019-09-27 06:19:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-27 06:19:18 +0000 |
commit | ad773d31e210e4828a40e0b6d2a191592a29451a (patch) | |
tree | a5bbff9d564d55d2417c6319e3cdae3d1b8b0970 /lib | |
parent | 4ca445c722d283c7cc11dfeb0e50e2d490a3515b (diff) | |
parent | bad07dfac57c36dff1c7b3fd4020fea806d7be93 (diff) |
Merge pull request #69345 from joachifm/feat/split-version
Replace uses of splitString for splitting version strings
Diffstat (limited to 'lib')
-rw-r--r-- | lib/default.nix | 2 | ||||
-rw-r--r-- | lib/tests/misc.nix | 15 | ||||
-rw-r--r-- | lib/versions.nix | 12 |
3 files changed, 24 insertions, 5 deletions
diff --git a/lib/default.nix b/lib/default.nix index 18d2dfae1e18..f293a1defb11 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -134,5 +134,7 @@ let mergeAttrsByFuncDefaultsClean mergeAttrBy fakeSha256 fakeSha512 nixType imap; + inherit (versions) + splitVersion; }); in lib diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index d8f412d3fc49..e5d76d4e57b7 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -102,6 +102,21 @@ runTests { expected = [ "2001" "db8" "0" "0042" "" "8a2e" "370" "" ]; }; + testSplitVersionSingle = { + expr = versions.splitVersion "1"; + expected = [ "1" ]; + }; + + testSplitVersionDouble = { + expr = versions.splitVersion "1.2"; + expected = [ "1" "2" ]; + }; + + testSplitVersionTriple = { + expr = versions.splitVersion "1.2.3"; + expected = [ "1" "2" "3" ]; + }; + testIsStorePath = { expr = let goodPath = diff --git a/lib/versions.nix b/lib/versions.nix index 2c05445b3dd0..0e9d81ac78b1 100644 --- a/lib/versions.nix +++ b/lib/versions.nix @@ -1,13 +1,15 @@ /* Version string functions. */ { lib }: -let +rec { - splitVersion = builtins.splitVersion or (lib.splitString "."); - -in + /* Break a version string into its component parts. -{ + Example: + splitVersion "1.2.3" + => ["1" "2" "3"] + */ + splitVersion = builtins.splitVersion or (lib.splitString "."); /* Get the major version string from a string. |