lib.replaceChars: warn about being a deprecated alias

replaceStrings has been in nix since 2015(nix 1.10)

so it is safe to remove the fallback

d6d5885c15
This commit is contained in:
Artturin 2022-12-12 03:36:03 +02:00
parent 084fd69045
commit 05a2dfd674
47 changed files with 64 additions and 75 deletions

View file

@ -328,7 +328,7 @@ rec {
escape ["(" ")"] "(foo)" escape ["(" ")"] "(foo)"
=> "\\(foo\\)" => "\\(foo\\)"
*/ */
escape = list: replaceChars list (map (c: "\\${c}") list); escape = list: replaceStrings list (map (c: "\\${c}") list);
/* Escape occurence of the element of `list` in `string` by /* Escape occurence of the element of `list` in `string` by
converting to its ASCII value and prefixing it with \\x. converting to its ASCII value and prefixing it with \\x.
@ -341,7 +341,7 @@ rec {
=> "foo\\x20bar" => "foo\\x20bar"
*/ */
escapeC = list: replaceChars list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list); escapeC = list: replaceStrings list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list);
/* Quote string to be used safely within the Bourne shell. /* Quote string to be used safely within the Bourne shell.
@ -471,19 +471,8 @@ rec {
["\"" "'" "<" ">" "&"] ["\"" "'" "<" ">" "&"]
["&quot;" "&apos;" "&lt;" "&gt;" "&amp;"]; ["&quot;" "&apos;" "&lt;" "&gt;" "&amp;"];
# Obsolete - use replaceStrings instead. # warning added 12-12-2022
replaceChars = builtins.replaceStrings or ( replaceChars = lib.warn "replaceChars is a deprecated alias of replaceStrings, replace usages of it with replaceStrings." builtins.replaceStrings;
del: new: s:
let
substList = lib.zipLists del new;
subst = c:
let found = lib.findFirst (sub: sub.fst == c) null substList; in
if found == null then
c
else
found.snd;
in
stringAsChars subst s);
# Case conversion utilities. # Case conversion utilities.
lowerChars = stringToCharacters "abcdefghijklmnopqrstuvwxyz"; lowerChars = stringToCharacters "abcdefghijklmnopqrstuvwxyz";
@ -497,7 +486,7 @@ rec {
toLower "HOME" toLower "HOME"
=> "home" => "home"
*/ */
toLower = replaceChars upperChars lowerChars; toLower = replaceStrings upperChars lowerChars;
/* Converts an ASCII string to upper-case. /* Converts an ASCII string to upper-case.
@ -507,7 +496,7 @@ rec {
toUpper "home" toUpper "home"
=> "HOME" => "HOME"
*/ */
toUpper = replaceChars lowerChars upperChars; toUpper = replaceStrings lowerChars upperChars;
/* Appends string context from another string. This is an implementation /* Appends string context from another string. This is an implementation
detail of Nix and should be used carefully. detail of Nix and should be used carefully.

View file

@ -8,9 +8,9 @@ let
systemd = cfg.package; systemd = cfg.package;
in rec { in rec {
shellEscape = s: (replaceChars [ "\\" ] [ "\\\\" ] s); shellEscape = s: (replaceStrings [ "\\" ] [ "\\\\" ] s);
mkPathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""]; mkPathSafeName = lib.replaceStrings ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""];
# a type for options that take a unit name # a type for options that take a unit name
unitNameType = types.strMatching "[a-zA-Z0-9@%:_.\\-]+[.](service|socket|device|mount|automount|swap|target|path|timer|scope|slice)"; unitNameType = types.strMatching "[a-zA-Z0-9@%:_.\\-]+[.](service|socket|device|mount|automount|swap|target|path|timer|scope|slice)";
@ -258,7 +258,7 @@ in rec {
makeJobScript = name: text: makeJobScript = name: text:
let let
scriptName = replaceChars [ "\\" "@" ] [ "-" "_" ] (shellEscape name); scriptName = replaceStrings [ "\\" "@" ] [ "-" "_" ] (shellEscape name);
out = (pkgs.writeShellScriptBin scriptName '' out = (pkgs.writeShellScriptBin scriptName ''
set -e set -e
${text} ${text}

View file

@ -48,7 +48,7 @@ rec {
trim = s: removeSuffix "/" (removePrefix "/" s); trim = s: removeSuffix "/" (removePrefix "/" s);
normalizedPath = strings.normalizePath s; normalizedPath = strings.normalizePath s;
in in
replaceChars ["/"] ["-"] replaceStrings ["/"] ["-"]
(replacePrefix "." (strings.escapeC ["."] ".") (replacePrefix "." (strings.escapeC ["."] ".")
(strings.escapeC (stringToCharacters " !\"#$%&'()*+,;<=>=@[\\]^`{|}~-") (strings.escapeC (stringToCharacters " !\"#$%&'()*+,;<=>=@[\\]^`{|}~-")
(if normalizedPath == "/" then normalizedPath else trim normalizedPath))); (if normalizedPath == "/" then normalizedPath else trim normalizedPath)));
@ -67,7 +67,7 @@ rec {
else if builtins.isInt arg || builtins.isFloat arg then toString arg else if builtins.isInt arg || builtins.isFloat arg then toString arg
else throw "escapeSystemdExecArg only allows strings, paths and numbers"; else throw "escapeSystemdExecArg only allows strings, paths and numbers";
in in
replaceChars [ "%" "$" ] [ "%%" "$$" ] (builtins.toJSON s); replaceStrings [ "%" "$" ] [ "%%" "$$" ] (builtins.toJSON s);
# Quotes a list of arguments into a single string for use in a Exec* # Quotes a list of arguments into a single string for use in a Exec*
# line. # line.
@ -112,7 +112,7 @@ rec {
else if isAttrs item then else if isAttrs item then
map (name: map (name:
let let
escapedName = ''"${replaceChars [''"'' "\\"] [''\"'' "\\\\"] name}"''; escapedName = ''"${replaceStrings [''"'' "\\"] [''\"'' "\\\\"] name}"'';
in in
recurse (prefix + "." + escapedName) item.${name}) (attrNames item) recurse (prefix + "." + escapedName) item.${name}) (attrNames item)
else if isList item then else if isList item then

View file

@ -160,7 +160,7 @@ let
config = rec { config = rec {
device = mkIf options.label.isDefined device = mkIf options.label.isDefined
"/dev/disk/by-label/${config.label}"; "/dev/disk/by-label/${config.label}";
deviceName = lib.replaceChars ["\\"] [""] (escapeSystemdPath config.device); deviceName = lib.replaceStrings ["\\"] [""] (escapeSystemdPath config.device);
realDevice = if config.randomEncryption.enable then "/dev/mapper/${deviceName}" else config.device; realDevice = if config.randomEncryption.enable then "/dev/mapper/${deviceName}" else config.device;
}; };

View file

@ -94,7 +94,7 @@ in
''; '';
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ ((replaceChars [ "/" ] [ "-" ] opts.fileSystem) + ".mount") ]; after = [ ((replaceStrings [ "/" ] [ "-" ] opts.fileSystem) + ".mount") ];
restartTriggers = [ config.environment.etc.projects.source ]; restartTriggers = [ config.environment.etc.projects.source ];

View file

@ -8,7 +8,7 @@ let
# Escaping is done according to https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS # Escaping is done according to https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS
setDatabaseOption = key: value: setDatabaseOption = key: value:
"UPDATE settings SET value = '${ "UPDATE settings SET value = '${
lib.replaceChars [ "'" ] [ "''" ] (builtins.toJSON value) lib.replaceStrings [ "'" ] [ "''" ] (builtins.toJSON value)
}' WHERE key = '${key}';"; }' WHERE key = '${key}';";
updateDatabaseConfigSQL = pkgs.writeText "update-database-config.sql" updateDatabaseConfigSQL = pkgs.writeText "update-database-config.sql"
(concatStringsSep "\n" (mapAttrsToList setDatabaseOption (concatStringsSep "\n" (mapAttrsToList setDatabaseOption

View file

@ -13,7 +13,7 @@ let
serviceName = iface: "supplicant-${if (iface=="WLAN") then "wlan@" else ( serviceName = iface: "supplicant-${if (iface=="WLAN") then "wlan@" else (
if (iface=="LAN") then "lan@" else ( if (iface=="LAN") then "lan@" else (
if (iface=="DBUS") then "dbus" if (iface=="DBUS") then "dbus"
else (replaceChars [" "] ["-"] iface)))}"; else (replaceStrings [" "] ["-"] iface)))}";
# TODO: Use proper privilege separation for wpa_supplicant # TODO: Use proper privilege separation for wpa_supplicant
supplicantService = iface: suppl: supplicantService = iface: suppl:
@ -27,7 +27,7 @@ let
driverArg = optionalString (suppl.driver != null) "-D${suppl.driver}"; driverArg = optionalString (suppl.driver != null) "-D${suppl.driver}";
bridgeArg = optionalString (suppl.bridge!="") "-b${suppl.bridge}"; bridgeArg = optionalString (suppl.bridge!="") "-b${suppl.bridge}";
confFileArg = optionalString (suppl.configFile.path!=null) "-c${suppl.configFile.path}"; confFileArg = optionalString (suppl.configFile.path!=null) "-c${suppl.configFile.path}";
extraConfFile = pkgs.writeText "supplicant-extra-conf-${replaceChars [" "] ["-"] iface}" '' extraConfFile = pkgs.writeText "supplicant-extra-conf-${replaceStrings [" "] ["-"] iface}" ''
${optionalString suppl.userControlled.enable "ctrl_interface=DIR=${suppl.userControlled.socketDir} GROUP=${suppl.userControlled.group}"} ${optionalString suppl.userControlled.enable "ctrl_interface=DIR=${suppl.userControlled.socketDir} GROUP=${suppl.userControlled.group}"}
${optionalString suppl.configFile.writable "update_config=1"} ${optionalString suppl.configFile.writable "update_config=1"}
${suppl.extraConf} ${suppl.extraConf}
@ -223,7 +223,7 @@ in
text = '' text = ''
${flip (concatMapStringsSep "\n") (filter (n: n!="WLAN" && n!="LAN" && n!="DBUS") (attrNames cfg)) (iface: ${flip (concatMapStringsSep "\n") (filter (n: n!="WLAN" && n!="LAN" && n!="DBUS") (attrNames cfg)) (iface:
flip (concatMapStringsSep "\n") (splitString " " iface) (i: '' flip (concatMapStringsSep "\n") (splitString " " iface) (i: ''
ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="${i}", TAG+="systemd", ENV{SYSTEMD_WANTS}+="supplicant-${replaceChars [" "] ["-"] iface}.service", TAG+="SUPPLICANT_ASSIGNED"''))} ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="${i}", TAG+="systemd", ENV{SYSTEMD_WANTS}+="supplicant-${replaceStrings [" "] ["-"] iface}.service", TAG+="SUPPLICANT_ASSIGNED"''))}
${optionalString (hasAttr "WLAN" cfg) '' ${optionalString (hasAttr "WLAN" cfg) ''
ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", TAG!="SUPPLICANT_ASSIGNED", TAG+="systemd", PROGRAM="/run/current-system/systemd/bin/systemd-escape -p %E{INTERFACE}", ENV{SYSTEMD_WANTS}+="supplicant-wlan@$result.service" ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", TAG!="SUPPLICANT_ASSIGNED", TAG+="systemd", PROGRAM="/run/current-system/systemd/bin/systemd-escape -p %E{INTERFACE}", ENV{SYSTEMD_WANTS}+="supplicant-wlan@$result.service"

View file

@ -315,7 +315,7 @@ let
peerUnitServiceName = interfaceName: publicKey: dynamicRefreshEnabled: peerUnitServiceName = interfaceName: publicKey: dynamicRefreshEnabled:
let let
keyToUnitName = replaceChars keyToUnitName = replaceStrings
[ "/" "-" " " "+" "=" ] [ "/" "-" " " "+" "=" ]
[ "-" "\\x2d" "\\x20" "\\x2b" "\\x3d" ]; [ "-" "\\x2d" "\\x20" "\\x2b" "\\x3d" ];
unitName = keyToUnitName publicKey; unitName = keyToUnitName publicKey;

View file

@ -38,7 +38,7 @@ let
grubConfig = args: grubConfig = args:
let let
efiSysMountPoint = if args.efiSysMountPoint == null then args.path else args.efiSysMountPoint; efiSysMountPoint = if args.efiSysMountPoint == null then args.path else args.efiSysMountPoint;
efiSysMountPoint' = replaceChars [ "/" ] [ "-" ] efiSysMountPoint; efiSysMountPoint' = replaceStrings [ "/" ] [ "-" ] efiSysMountPoint;
in in
pkgs.writeText "grub-config.xml" (builtins.toXML pkgs.writeText "grub-config.xml" (builtins.toXML
{ splashImage = f cfg.splashImage; { splashImage = f cfg.splashImage;

View file

@ -1377,12 +1377,12 @@ in
# networkmanager falls back to "/proc/sys/net/ipv6/conf/default/use_tempaddr" # networkmanager falls back to "/proc/sys/net/ipv6/conf/default/use_tempaddr"
"net.ipv6.conf.default.use_tempaddr" = tempaddrValues.${cfg.tempAddresses}.sysctl; "net.ipv6.conf.default.use_tempaddr" = tempaddrValues.${cfg.tempAddresses}.sysctl;
} // listToAttrs (forEach interfaces } // listToAttrs (forEach interfaces
(i: nameValuePair "net.ipv4.conf.${replaceChars ["."] ["/"] i.name}.proxy_arp" i.proxyARP)) (i: nameValuePair "net.ipv4.conf.${replaceStrings ["."] ["/"] i.name}.proxy_arp" i.proxyARP))
// listToAttrs (forEach interfaces // listToAttrs (forEach interfaces
(i: let (i: let
opt = i.tempAddress; opt = i.tempAddress;
val = tempaddrValues.${opt}.sysctl; val = tempaddrValues.${opt}.sysctl;
in nameValuePair "net.ipv6.conf.${replaceChars ["."] ["/"] i.name}.use_tempaddr" val)); in nameValuePair "net.ipv6.conf.${replaceStrings ["."] ["/"] i.name}.use_tempaddr" val));
security.wrappers = { security.wrappers = {
ping = { ping = {
@ -1495,7 +1495,7 @@ in
in in
'' ''
# override to ${msg} for ${i.name} # override to ${msg} for ${i.name}
ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.procps}/bin/sysctl net.ipv6.conf.${replaceChars ["."] ["/"] i.name}.use_tempaddr=${val}" ACTION=="add", SUBSYSTEM=="net", RUN+="${pkgs.procps}/bin/sysctl net.ipv6.conf.${replaceStrings ["."] ["/"] i.name}.use_tempaddr=${val}"
'') (filter (i: i.tempAddress != cfg.tempAddresses) interfaces); '') (filter (i: i.tempAddress != cfg.tempAddresses) interfaces);
}) })
] ++ lib.optional (cfg.wlanInterfaces != {}) ] ++ lib.optional (cfg.wlanInterfaces != {})

View file

@ -57,7 +57,7 @@ let
hardware.enableAllFirmware = lib.mkForce false; hardware.enableAllFirmware = lib.mkForce false;
${replaceChars ["\n"] ["\n "] extraConfig} ${replaceStrings ["\n"] ["\n "] extraConfig}
} }
''; '';

View file

@ -6,7 +6,7 @@
let let
inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest; inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
inherit (pkgs.lib) concatStringsSep maintainers mapAttrs mkMerge inherit (pkgs.lib) concatStringsSep maintainers mapAttrs mkMerge
removeSuffix replaceChars singleton splitString; removeSuffix replaceStrings singleton splitString;
/* /*
* The attrset `exporterTests` contains one attribute * The attrset `exporterTests` contains one attribute
@ -182,7 +182,7 @@ let
enable = true; enable = true;
extraFlags = [ "--web.collectd-push-path /collectd" ]; extraFlags = [ "--web.collectd-push-path /collectd" ];
}; };
exporterTest = let postData = replaceChars [ "\n" ] [ "" ] '' exporterTest = let postData = replaceStrings [ "\n" ] [ "" ] ''
[{ [{
"values":[23], "values":[23],
"dstypes":["gauge"], "dstypes":["gauge"],

View file

@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "munt"; owner = "munt";
repo = "munt"; repo = "munt";
rev = "${pname}_${lib.replaceChars [ "." ] [ "_" ] version}"; rev = "${pname}_${lib.replaceStrings [ "." ] [ "_" ] version}";
sha256 = "sha256-XGds9lDfSiY0D8RhYG4TGyjYEVvVYuAfNSv9+VxiJEs="; sha256 = "sha256-XGds9lDfSiY0D8RhYG4TGyjYEVvVYuAfNSv9+VxiJEs=";
}; };

View file

@ -14,7 +14,7 @@
}: }:
let let
char2underscore = char: str: lib.replaceChars [ char ] [ "_" ] str; char2underscore = char: str: lib.replaceStrings [ char ] [ "_" ] str;
in in
mkDerivation rec { mkDerivation rec {
pname = "mt32emu-qt"; pname = "mt32emu-qt";

View file

@ -8,7 +8,7 @@
}: }:
let let
char2underscore = char: str: lib.replaceChars [ char ] [ "_" ] str; char2underscore = char: str: lib.replaceStrings [ char ] [ "_" ] str;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "mt32emu-smf2wav"; pname = "mt32emu-smf2wav";

View file

@ -13,7 +13,7 @@ mkDerivation rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "rncbc"; owner = "rncbc";
repo = "qjackctl"; repo = "qjackctl";
rev = "${pname}_${lib.replaceChars ["."] ["_"] version}"; rev = "${pname}_${lib.replaceStrings ["."] ["_"] version}";
sha256 = "sha256-PchW9cM5qEP51G9RXUZ3j/AvKqTkgNiw3esqSQqsy0M="; sha256 = "sha256-PchW9cM5qEP51G9RXUZ3j/AvKqTkgNiw3esqSQqsy0M=";
}; };

View file

@ -17,7 +17,7 @@ stdenv.mkDerivation rec {
version = "5.20.5"; version = "5.20.5";
src = fetchurl { src = fetchurl {
url = "https://www.roomeqwizard.com/installers/REW_linux_${lib.replaceChars [ "." ] [ "_" ] version}.sh"; url = "https://www.roomeqwizard.com/installers/REW_linux_${lib.replaceStrings [ "." ] [ "_" ] version}.sh";
sha256 = "NYTRiOZmwkni4k+jI2SV84z5umO7+l+eKpwPCdlDD3U="; sha256 = "NYTRiOZmwkni4k+jI2SV84z5umO7+l+eKpwPCdlDD3U=";
}; };

View file

@ -21,7 +21,7 @@ with stdenv; lib.makeOverridable mkDerivation (rec {
desktopItem = makeDesktopItem { desktopItem = makeDesktopItem {
name = pname; name = pname;
exec = pname; exec = pname;
comment = lib.replaceChars ["\n"] [" "] meta.longDescription; comment = lib.replaceStrings ["\n"] [" "] meta.longDescription;
desktopName = product; desktopName = product;
genericName = meta.description; genericName = meta.description;
categories = [ "Development" ]; categories = [ "Development" ];

View file

@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "atari800"; owner = "atari800";
repo = "atari800"; repo = "atari800";
rev = "ATARI800_${replaceChars ["."] ["_"] version}"; rev = "ATARI800_${replaceStrings ["."] ["_"] version}";
sha256 = "sha256-+eJXhqPyU0GhmzF7DbteTXzEnn5klCor9Io/UgXQfQg="; sha256 = "sha256-+eJXhqPyU0GhmzF7DbteTXzEnn5klCor9Io/UgXQfQg=";
}; };

View file

@ -29,7 +29,7 @@ stdenv.mkDerivation (finalAttrs: {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "TASVideos"; owner = "TASVideos";
repo = "desmume"; repo = "desmume";
rev = "release_${lib.replaceChars ["."] ["_"] finalAttrs.version}"; rev = "release_${lib.replaceStrings ["."] ["_"] finalAttrs.version}";
hash = "sha256-vmjKXa/iXLTwtqnG+ZUvOnOQPZROeMpfM5J3Jh/Ynfo="; hash = "sha256-vmjKXa/iXLTwtqnG+ZUvOnOQPZROeMpfM5J3Jh/Ynfo=";
}; };

View file

@ -16,7 +16,7 @@
}@args: }@args:
let let
d2u = if normalizeCore then (lib.replaceChars [ "-" ] [ "_" ]) else (x: x); d2u = if normalizeCore then (lib.replaceStrings [ "-" ] [ "_" ]) else (x: x);
coreDir = placeholder "out" + libretroCore; coreDir = placeholder "out" + libretroCore;
coreFilename = "${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary}"; coreFilename = "${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary}";
mainProgram = "retroarch-${core}"; mainProgram = "retroarch-${core}";

View file

@ -105,7 +105,7 @@ let
}; };
}; };
d2u = lib.replaceChars ["."] ["_"]; d2u = lib.replaceStrings ["."] ["_"];
in { in {

View file

@ -81,7 +81,7 @@ let
}; };
d2u = lib.replaceChars ["."] ["_"]; d2u = lib.replaceStrings ["."] ["_"];
in { in {

View file

@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
version = "3.9.6"; version = "3.9.6";
src = fetchurl { src = fetchurl {
url = "mirror://sourceforge/weka/${lib.replaceChars ["."]["-"] "${pname}-${version}"}.zip"; url = "mirror://sourceforge/weka/${lib.replaceStrings ["."]["-"] "${pname}-${version}"}.zip";
sha256 = "sha256-8fVN4MXYqXNEmyVtXh1IrauHTBZWgWG8AvsGI5Y9Aj0="; sha256 = "sha256-8fVN4MXYqXNEmyVtXh1IrauHTBZWgWG8AvsGI5Y9Aj0=";
}; };

View file

@ -13,7 +13,7 @@ let
hashname = r: hashname = r:
let let
rpl = lib.replaceChars [ ":" "/" ] [ "_" "_" ]; rpl = lib.replaceStrings [ ":" "/" ] [ "_" "_" ];
in in
(rpl r.url) + "-" + (rpl r.rev); (rpl r.url) + "-" + (rpl r.rev);

View file

@ -39,14 +39,14 @@ assert (repos != []) || (url != "") || (urls != []);
let let
name_ = name_ =
lib.concatStrings [ lib.concatStrings [
(lib.replaceChars ["."] ["_"] groupId) "_" (lib.replaceStrings ["."] ["_"] groupId) "_"
(lib.replaceChars ["."] ["_"] artifactId) "-" (lib.replaceStrings ["."] ["_"] artifactId) "-"
version version
]; ];
mkJarUrl = repoUrl: mkJarUrl = repoUrl:
lib.concatStringsSep "/" [ lib.concatStringsSep "/" [
(lib.removeSuffix "/" repoUrl) (lib.removeSuffix "/" repoUrl)
(lib.replaceChars ["."] ["/"] groupId) (lib.replaceStrings ["."] ["/"] groupId)
artifactId artifactId
version version
"${artifactId}-${version}${lib.optionalString (!isNull classifier) "-${classifier}"}.jar" "${artifactId}-${version}${lib.optionalString (!isNull classifier) "-${classifier}"}.jar"

View file

@ -32,7 +32,7 @@ let version_ = lib.splitString "-" crateVersion;
completeDepsDir = lib.concatStringsSep " " completeDeps; completeDepsDir = lib.concatStringsSep " " completeDeps;
completeBuildDepsDir = lib.concatStringsSep " " completeBuildDeps; completeBuildDepsDir = lib.concatStringsSep " " completeBuildDeps;
envFeatures = lib.concatStringsSep " " ( envFeatures = lib.concatStringsSep " " (
map (f: lib.replaceChars ["-"] ["_"] (lib.toUpper f)) crateFeatures map (f: lib.replaceStrings ["-"] ["_"] (lib.toUpper f)) crateFeatures
); );
in '' in ''
${echo_colored colors} ${echo_colored colors}

View file

@ -3,7 +3,7 @@
ver: deps: ver: deps:
let cmds = lib.mapAttrsToList (name: info: let let cmds = lib.mapAttrsToList (name: info: let
pkg = stdenv.mkDerivation { pkg = stdenv.mkDerivation {
name = lib.replaceChars ["/"] ["-"] name + "-${info.version}"; name = lib.replaceStrings ["/"] ["-"] name + "-${info.version}";
src = fetchurl { src = fetchurl {
url = "https://github.com/${name}/archive/${info.version}.tar.gz"; url = "https://github.com/${name}/archive/${info.version}.tar.gz";

View file

@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "shirok"; owner = "shirok";
repo = pname; repo = pname;
rev = "release${lib.replaceChars [ "." ] [ "_" ] version}"; rev = "release${lib.replaceStrings [ "." ] [ "_" ] version}";
sha256 = "0ki1w7sa10ivmg51sqjskby0gsznb0d3738nz80x589033km5hmb"; sha256 = "0ki1w7sa10ivmg51sqjskby0gsznb0d3738nz80x589033km5hmb";
}; };

View file

@ -9,7 +9,7 @@ let
baseAttrs = { baseAttrs = {
src = fetchurl { src = fetchurl {
url = "https://github.com/unicode-org/icu/releases/download/release-${lib.replaceChars [ "." ] [ "-" ] version}/icu4c-${lib.replaceChars [ "." ] [ "_" ] version}-src.tgz"; url = "https://github.com/unicode-org/icu/releases/download/release-${lib.replaceStrings [ "." ] [ "-" ] version}/icu4c-${lib.replaceStrings [ "." ] [ "_" ] version}-src.tgz";
inherit sha256; inherit sha256;
}; };

View file

@ -3,7 +3,7 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "hsqldb"; pname = "hsqldb";
version = "2.7.1"; version = "2.7.1";
underscoreMajMin = lib.strings.replaceChars ["."] ["_"] (lib.versions.majorMinor version); underscoreMajMin = lib.replaceStrings ["."] ["_"] (lib.versions.majorMinor version);
src = fetchurl { src = fetchurl {
url = "mirror://sourceforge/project/hsqldb/hsqldb/hsqldb_${underscoreMajMin}/hsqldb-${version}.zip"; url = "mirror://sourceforge/project/hsqldb/hsqldb/hsqldb_${underscoreMajMin}/hsqldb-${version}.zip";

View file

@ -3,7 +3,7 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "muparser"; pname = "muparser";
version = "2.2.3"; version = "2.2.3";
url-version = lib.replaceChars ["."] ["_"] version; url-version = lib.replaceStrings ["."] ["_"] version;
src = fetchurl { src = fetchurl {
url = "mirror://sourceforge/muparser/muparser_v${url-version}.zip"; url = "mirror://sourceforge/muparser/muparser_v${url-version}.zip";

View file

@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "trusteddomainproject"; owner = "trusteddomainproject";
repo = "OpenDKIM"; repo = "OpenDKIM";
rev = "rel-opendkim-${lib.replaceChars ["."] ["-"] version}"; rev = "rel-opendkim-${lib.replaceStrings ["."] ["-"] version}";
sha256 = "0nx3in8sa6xna4vfacj8g60hfzk61jpj2ldag80xzxip9c3rd2pw"; sha256 = "0nx3in8sa6xna4vfacj8g60hfzk61jpj2ldag80xzxip9c3rd2pw";
}; };

View file

@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "PixarAnimationStudios"; owner = "PixarAnimationStudios";
repo = "OpenSubdiv"; repo = "OpenSubdiv";
rev = "v${lib.replaceChars ["."] ["_"] version}"; rev = "v${lib.replaceStrings ["."] ["_"] version}";
sha256 = "sha256-ejxQ5mGIIrEa/rAfkTrRbIRerrAvEPoWn7e0lIqS1JQ="; sha256 = "sha256-ejxQ5mGIIrEa/rAfkTrRbIRerrAvEPoWn7e0lIqS1JQ=";
}; };

View file

@ -16,7 +16,7 @@ let
extraArgs = removeAttrs args ([ "name" ] ++ builtins.attrNames androidSdkFormalArgs); extraArgs = removeAttrs args ([ "name" ] ++ builtins.attrNames androidSdkFormalArgs);
in in
stdenv.mkDerivation ({ stdenv.mkDerivation ({
name = lib.replaceChars [" "] [""] name; # Android APKs may contain white spaces in their names, but Nix store paths cannot name = lib.replaceStrings [" "] [""] name; # Android APKs may contain white spaces in their names, but Nix store paths cannot
ANDROID_HOME = "${androidsdk}/libexec/android-sdk"; ANDROID_HOME = "${androidsdk}/libexec/android-sdk";
buildInputs = [ jdk ant ]; buildInputs = [ jdk ant ];
buildPhase = '' buildPhase = ''

View file

@ -34,7 +34,7 @@ let
extraArgs = removeAttrs args [ "name" "preRebuild" "androidsdkArgs" "xcodewrapperArgs" ]; extraArgs = removeAttrs args [ "name" "preRebuild" "androidsdkArgs" "xcodewrapperArgs" ];
in in
stdenv.mkDerivation ({ stdenv.mkDerivation ({
name = lib.replaceChars [" "] [""] name; name = lib.replaceStrings [" "] [""] name;
buildInputs = [ nodejs titanium alloy python which file jdk ]; buildInputs = [ nodejs titanium alloy python which file jdk ];

View file

@ -53,7 +53,7 @@ let
extraArgs = removeAttrs args ([ "name" "scheme" "xcodeFlags" "release" "certificateFile" "certificatePassword" "provisioningProfile" "signMethod" "generateIPA" "generateXCArchive" "enableWirelessDistribution" "installURL" "bundleId" "version" ] ++ builtins.attrNames xcodewrapperFormalArgs); extraArgs = removeAttrs args ([ "name" "scheme" "xcodeFlags" "release" "certificateFile" "certificatePassword" "provisioningProfile" "signMethod" "generateIPA" "generateXCArchive" "enableWirelessDistribution" "installURL" "bundleId" "version" ] ++ builtins.attrNames xcodewrapperFormalArgs);
in in
stdenv.mkDerivation ({ stdenv.mkDerivation ({
name = lib.replaceChars [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed name = lib.replaceStrings [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed
buildPhase = '' buildPhase = ''
# Be sure that the Xcode wrapper has priority over everything else. # Be sure that the Xcode wrapper has priority over everything else.
# When using buildInputs this does not seem to be the case. # When using buildInputs this does not seem to be the case.

View file

@ -9,7 +9,7 @@ let
xcodewrapper = composeXcodeWrapper xcodewrapperArgs; xcodewrapper = composeXcodeWrapper xcodewrapperArgs;
in in
stdenv.mkDerivation { stdenv.mkDerivation {
name = lib.replaceChars [" "] [""] name; name = lib.replaceStrings [" "] [""] name;
buildCommand = '' buildCommand = ''
mkdir -p $out/bin mkdir -p $out/bin
cat > $out/bin/run-test-simulator << "EOF" cat > $out/bin/run-test-simulator << "EOF"

View file

@ -95,7 +95,7 @@ buildPythonPackage rec {
changelog = let changelog = let
major = versions.major version; major = versions.major version;
minor = versions.minor version; minor = versions.minor version;
dashVer = replaceChars ["."] ["-"] version; dashVer = replaceStrings ["."] ["-"] version;
in in
"https://scikit-learn.org/stable/whats_new/v${major}.${minor}.html#version-${dashVer}"; "https://scikit-learn.org/stable/whats_new/v${major}.${minor}.html#version-${dashVer}";
homepage = "https://scikit-learn.org"; homepage = "https://scikit-learn.org";

View file

@ -20,8 +20,8 @@ let allPkgs = pkgs: mueval.defaultPkgs pkgs ++ [ pkgs.lambdabot-trusted ] ++ pac
++ lib.optional withDjinn haskellPackages.djinn ++ lib.optional withDjinn haskellPackages.djinn
++ lib.optional (aspell != null) aspell ++ lib.optional (aspell != null) aspell
); );
modulesStr = lib.replaceChars ["\n"] [" "] modules; modulesStr = lib.replaceStrings ["\n"] [" "] modules;
configStr = lib.replaceChars ["\n"] [" "] configuration; configStr = lib.replaceStrings ["\n"] [" "] configuration;
in haskellLib.overrideCabal (self: { in haskellLib.overrideCabal (self: {
patches = (self.patches or []) ++ [ ./custom-config.patch ]; patches = (self.patches or []) ++ [ ./custom-config.patch ];

View file

@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
version = "3.22a"; version = "3.22a";
src = fetchurl { src = fetchurl {
url = "https://www.segger.com/downloads/jlink/Ozone_Linux_V${(lib.replaceChars ["."] [""] version)}_x86_64.tgz"; url = "https://www.segger.com/downloads/jlink/Ozone_Linux_V${(lib.replaceStrings ["."] [""] version)}_x86_64.tgz";
sha256 = "0v1r8qvp1w2f3yip9fys004pa0smlmq69p7w77lfvghs1rmg1649"; sha256 = "0v1r8qvp1w2f3yip9fys004pa0smlmq69p7w77lfvghs1rmg1649";
}; };

View file

@ -3,7 +3,7 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "kcgi"; pname = "kcgi";
version = "0.10.8"; version = "0.10.8";
underscoreVersion = lib.replaceChars ["."] ["_"] version; underscoreVersion = lib.replaceStrings ["."] ["_"] version;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "kristapsdz"; owner = "kristapsdz";

View file

@ -11,7 +11,7 @@
let let
version = "2.5.2"; version = "2.5.2";
version_short = lib.replaceChars [ "." ] [ "" ] version; version_short = lib.replaceStrings [ "." ] [ "" ] version;
in stdenv.mkDerivation { in stdenv.mkDerivation {
pname = "nexuiz"; pname = "nexuiz";
inherit version; inherit version;

View file

@ -3,7 +3,7 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "terraria-server"; pname = "terraria-server";
version = "1.4.4.9"; version = "1.4.4.9";
urlVersion = lib.replaceChars [ "." ] [ "" ] version; urlVersion = lib.replaceStrings [ "." ] [ "" ] version;
src = fetchurl { src = fetchurl {
url = "https://terraria.org/api/download/pc-dedicated-server/terraria-server-${urlVersion}.zip"; url = "https://terraria.org/api/download/pc-dedicated-server/terraria-server-${urlVersion}.zip";

View file

@ -44,7 +44,7 @@ crystal.buildCrystalPackage rec {
substituteInPlace src/invidious.cr \ substituteInPlace src/invidious.cr \
--replace ${lib.escapeShellArg branchTemplate} '"master"' \ --replace ${lib.escapeShellArg branchTemplate} '"master"' \
--replace ${lib.escapeShellArg commitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' \ --replace ${lib.escapeShellArg commitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' \
--replace ${lib.escapeShellArg versionTemplate} '"${lib.replaceChars ["-"] ["."] (lib.substring 9 10 version)}"' \ --replace ${lib.escapeShellArg versionTemplate} '"${lib.replaceStrings ["-"] ["."] (lib.substring 9 10 version)}"' \
--replace ${lib.escapeShellArg assetCommitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' --replace ${lib.escapeShellArg assetCommitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"'
# Patch the assets and locales paths to be absolute # Patch the assets and locales paths to be absolute

View file

@ -10,7 +10,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "pgf-tikz"; owner = "pgf-tikz";
repo = "pgf"; repo = "pgf";
rev = "refs/tags/version-${lib.replaceChars ["."] ["-"] finalAttrs.version}"; rev = "refs/tags/version-${lib.replaceStrings ["."] ["-"] finalAttrs.version}";
hash = "sha256-WZ/191iEDd5VK1bnV9JZx2BZfACUeAUhAqrlyx+ZvA4="; hash = "sha256-WZ/191iEDd5VK1bnV9JZx2BZfACUeAUhAqrlyx+ZvA4=";
}; };

View file

@ -4,7 +4,7 @@ let
self = haxePackages; self = haxePackages;
haxePackages = with self; { haxePackages = with self; {
withCommas = lib.replaceChars ["."] [","]; withCommas = lib.replaceStrings ["."] [","];
# simulate "haxelib dev $libname ." # simulate "haxelib dev $libname ."
simulateHaxelibDev = libname: '' simulateHaxelibDev = libname: ''