tree-wide: replace uses of splitString "." with lib.versions

Quoting from the splitString docstring:

   NOTE: this function is not performant and should never be used.

This replaces trivial uses of splitString for splitting version
strings with the (potentially builtin) splitVersion.
This commit is contained in:
Joachim Fasting 2019-09-24 11:24:13 +02:00
parent 2d4352b1ae
commit bad07dfac5
No known key found for this signature in database
GPG Key ID: 5C204DF675C90294
27 changed files with 35 additions and 39 deletions

View File

@ -12,7 +12,7 @@ let
php = mainCfg.phpPackage.override { apacheHttpd = httpd.dev; /* otherwise it only gets .out */ };
phpMajorVersion = head (splitString "." php.version);
phpMajorVersion = lib.versions.major (lib.getVersion php);
mod_perl = pkgs.apacheHttpdPackages.mod_perl.override { apacheHttpd = httpd; };

View File

@ -9,8 +9,7 @@ let
# OpenJPEG version is hardcoded in package source
openJpegVersion = with stdenv;
lib.concatStringsSep "." (lib.lists.take 2
(lib.splitString "." (lib.getVersion openjpeg)));
lib.versions.majorMinor (lib.getVersion openjpeg);
in stdenv.mkDerivation rec {

View File

@ -13,7 +13,7 @@ stdenv.mkDerivation rec {
in fetchFromGitHub {
sha256 = "0v2mx2idaxlsyv5w66b7pknlill9j9i2gqcs3vq54gak7ix9fj1p";
rev = with stdenv.lib;
"v" + concatStringsSep "_" (splitString "." version);
"v" + concatStringsSep "_" (splitVersion version);
repo = "workrave";
owner = "rcaelers";
};

View File

@ -10,7 +10,7 @@ with lib;
let
version = "3.11.0";
ver = stdenv.lib.elemAt (stdenv.lib.splitString "." version);
ver = stdenv.lib.elemAt (stdenv.lib.splitVersion version);
versionMajor = ver 0;
versionMinor = ver 1;
versionPatch = ver 2;

View File

@ -28,7 +28,7 @@ stdenv.mkDerivation rec {
# Includes a fix for the embedded soname being libyices.so.2.5, but
# only installing the libyices.so.2.5.x file.
installPhase = let
ver_XdotY = builtins.concatStringsSep "." (stdenv.lib.take 2 (stdenv.lib.splitString "." version));
ver_XdotY = stdenv.lib.versions.majorMinor version;
in ''
make install LDCONFIG=true
ln -sfr $out/lib/libyices.so.{${version},${ver_XdotY}}

View File

@ -3,7 +3,7 @@
let
version = virtualbox.version;
xserverVListFunc = builtins.elemAt (stdenv.lib.splitString "." xorg.xorgserver.version);
xserverVListFunc = builtins.elemAt (stdenv.lib.splitVersion xorg.xorgserver.version);
# Forced to 1.18 in <nixpkgs/nixos/modules/services/x11/xserver.nix>
# as it even fails to build otherwise. Still, override this even here,

View File

@ -21,7 +21,7 @@
, workspace_member }:
let version_ = lib.splitString "-" crateVersion;
versionPre = if lib.tail version_ == [] then "" else builtins.elemAt version_ 1;
version = lib.splitString "." (lib.head version_);
version = lib.splitVersion (lib.head version_);
rustcOpts = lib.lists.foldl' (opts: opt: opts + " " + opt)
(if release then "-C opt-level=3" else "-C debuginfo=2")
(["-C codegen-units=$NIX_BUILD_CORES"] ++ extraRustcOpts);
@ -150,4 +150,3 @@ in ''
fi
runHook postConfigure
''

View File

@ -180,9 +180,7 @@ let
'';
passthru = {
cc = gcc;
majorVersion =
let versionParts = lib.splitString "." version;
in "${lib.elemAt versionParts 0}.${lib.elemAt versionParts 1}";
majorVersion = lib.versions.majorMinor version;
};
meta = with stdenv.lib; {

View File

@ -22,7 +22,7 @@ assert (stdenv.hostPlatform != stdenv.buildPlatform) -> !enableSharedLibraries;
let
# Used when creating a versioned symlinks of libLLVM.dylib
versionSuffixes = with stdenv.lib;
let parts = splitString "." version; in
let parts = splitVersion version; in
imap (i: _: concatStringsSep "." (take i parts)) parts;
in

View File

@ -19,7 +19,7 @@
let
# Used when creating a versioned symlinks of libLLVM.dylib
versionSuffixes = with stdenv.lib;
let parts = splitString "." release_version; in
let parts = splitVersion release_version; in
imap (i: _: concatStringsSep "." (take i parts)) parts;
in

View File

@ -18,7 +18,7 @@
let
# Used when creating a versioned symlinks of libLLVM.dylib
versionSuffixes = with stdenv.lib;
let parts = splitString "." release_version; in
let parts = splitVersion release_version; in
imap (i: _: concatStringsSep "." (take i parts)) parts;
in

View File

@ -21,7 +21,7 @@ let
# Used when creating a versioned symlinks of libLLVM.dylib
versionSuffixes = with stdenv.lib;
let parts = splitString "." release_version; in
let parts = splitVersion release_version; in
imap (i: _: concatStringsSep "." (take i parts)) parts;
in

View File

@ -26,7 +26,7 @@ let
# Used when creating a versioned symlinks of libLLVM.dylib
versionSuffixes = with stdenv.lib;
let parts = splitString "." release_version; in
let parts = splitVersion release_version; in
imap (i: _: concatStringsSep "." (take i parts)) parts;
in stdenv.mkDerivation ({

View File

@ -25,7 +25,7 @@ let
# Used when creating a version-suffixed symlink of libLLVM.dylib
shortVersion = with stdenv.lib;
concatStringsSep "." (take 1 (splitString "." release_version));
concatStringsSep "." (take 1 (splitVersion release_version));
in stdenv.mkDerivation ({
name = "llvm-${version}";

View File

@ -9,9 +9,9 @@
}:
let
inherit (stdenv.lib) getVersion versionAtLeast splitString head;
inherit (stdenv.lib) getVersion versionAtLeast versions;
mainVersion = head (splitString "." (getVersion erlang));
mainVersion = versions.major (getVersion erlang);
proper = buildHex {
name = "proper";

View File

@ -28,7 +28,7 @@ with stdenv.lib;
let
version = "19.1.5";
branch = head (splitString "." version);
branch = versions.major version;
in
stdenv.mkDerivation {

View File

@ -46,7 +46,7 @@ stdenv.mkDerivation {
passthru = {
inherit cudatoolkit;
majorVersion = lib.head (lib.splitString "." version);
majorVersion = lib.versions.major version;
};
meta = with stdenv.lib; {

View File

@ -1,9 +1,9 @@
lib: version:
with lib;
let
fragments = splitString "." version;
fragments = splitVersion version;
major = head fragments;
minor = concatMapStrings (fixedWidthNumber 2) (tail fragments);
in

View File

@ -29,7 +29,7 @@ with super;
# Parse out a version number without the Lua version inserted
version = with pkgs.lib; let
version' = super.cqueues.version;
rel = splitString "." version';
rel = splitVersion version';
date = head rel;
rev = last (splitString "-" (last rel));
in "${date}-${rev}";

View File

@ -26,7 +26,7 @@ let
i686-cygwin = "win32";
};
dfVersionTriple = splitString "." dfVersion;
dfVersionTriple = splitVersion dfVersion;
baseVersion = elemAt dfVersionTriple 1;
patchVersion = elemAt dfVersionTriple 2;

View File

@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
version = "2.0.5";
src = let
version2 = concatStrings (splitString "." version);
version2 = replaceStrings ["."] [""] version;
platform = "linux" + (optionalString stdenv.is64bit "_x64");
in fetchurl {
url = "https://www.epsxe.com/files/ePSXe${version2}${platform}.zip";

View File

@ -68,9 +68,9 @@ let
} // lib.optionalAttrs stdenv'.isDarwin {
MKRELRO = "no";
} // lib.optionalAttrs (stdenv'.cc.isClang or false) {
HAVE_LLVM = lib.head (lib.splitString "." (lib.getVersion stdenv'.cc.cc));
HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
} // lib.optionalAttrs (stdenv'.cc.isGNU or false) {
HAVE_GCC = lib.head (lib.splitString "." (lib.getVersion stdenv'.cc.cc));
HAVE_GCC = lib.versions.major (lib.getVersion stdenv'.cc.cc);
} // lib.optionalAttrs (attrs.headersOnly or false) {
installPhase = "includesPhase";
dontBuild = true;

View File

@ -6,10 +6,10 @@ buildLinux (args // rec {
version = "4.14.145";
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
modDirVersion = if (modDirVersionArg == null) then concatStrings (intersperse "." (take 3 (splitString "." "${version}.0"))) else modDirVersionArg;
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
# branchVersion needs to be x.y
extraMeta.branch = concatStrings (intersperse "." (take 2 (splitString "." version)));
extraMeta.branch = versions.majorMinor version;
src = fetchurl {
url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";

View File

@ -6,10 +6,10 @@ buildLinux (args // rec {
version = "4.19.74";
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
modDirVersion = if (modDirVersionArg == null) then concatStrings (intersperse "." (take 3 (splitString "." "${version}.0"))) else modDirVersionArg;
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
# branchVersion needs to be x.y
extraMeta.branch = concatStrings (intersperse "." (take 2 (splitString "." version)));
extraMeta.branch = versions.majorMinor version;
src = fetchurl {
url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";

View File

@ -6,10 +6,10 @@ buildLinux (args // rec {
version = "5.2.16";
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
modDirVersion = if (modDirVersionArg == null) then concatStrings (intersperse "." (take 3 (splitString "." "${version}.0"))) else modDirVersionArg;
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
# branchVersion needs to be x.y
extraMeta.branch = concatStrings (intersperse "." (take 2 (splitString "." version)));
extraMeta.branch = versions.majorMinor version;
src = fetchurl {
url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz";

View File

@ -6,10 +6,10 @@ buildLinux (args // rec {
version = "5.3";
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
modDirVersion = if (modDirVersionArg == null) then concatStrings (intersperse "." (take 3 (splitString "." "${version}.0"))) else modDirVersionArg;
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
# branchVersion needs to be x.y
extraMeta.branch = concatStrings (intersperse "." (take 2 (splitString "." version)));
extraMeta.branch = versions.majorMinor version;
src = fetchurl {
url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz";

View File

@ -8,8 +8,8 @@ assert (!libsOnly) -> kernel != null;
# Disable for kernels 4.15 and above due to compatibility issues
assert kernel != null -> stdenv.lib.versionOlder kernel.version "4.15";
let xorgFullVer = (builtins.parseDrvName xorg.xorgserver.name).version;
xorgVer = lib.concatStringsSep "." (lib.take 2 (lib.splitString "." xorgFullVer));
let xorgFullVer = lib.getVersion xorg.xorgserver;
xorgVer = lib.versions.majorMinor xorgFullVer;
x64 = if stdenv.hostPlatform.system == "x86_64-linux" then true
else if stdenv.hostPlatform.system == "i686-linux" then false
else throw "Parallels Tools for Linux only support {x86-64,i686}-linux targets";