mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
treewide: drop unnecessary toString calls
Scope:
- Combination of
- Textual matches of "baseNameOf (toString"
- Redundant toString calls I've found with my latest
"lazy paths" nix branch as they force lazy fetches into
the store. More info and new PR soon.
- Only cases I believe are worthwhile or easily determined
I've determined the validity by
- testing llvmPackages instantiation
- figuring out which types can pass into any particular
toString call - "human fuzzy type checker"
Behavior considerations by type:
- `path`: converted back to a string *without* context
`baseNameOf` does not copy things to the store on its own,
equivalent to its behavior for string inputs
- `null`: converted to `""` -> may be valid input!
ok if "" would not have been acceptable anyway
- `string` itself: passed through identically -> trivial
- `attrset` with `outPath`: same coercion as built into
the `baseNameOf` function -> trivial
- other atomic types: generally not sensible inputs to
`baseNameOf` -> fuzzy but true
This commit is contained in:
parent
8a570f5d13
commit
235013cf37
7 changed files with 13 additions and 16 deletions
|
|
@ -43,7 +43,7 @@ let
|
|||
cleanSourceFilter =
|
||||
name: type:
|
||||
let
|
||||
baseName = baseNameOf (toString name);
|
||||
baseName = baseNameOf name;
|
||||
in
|
||||
!(
|
||||
# Filter out version control software files/directories
|
||||
|
|
@ -270,7 +270,7 @@ let
|
|||
filter =
|
||||
name: type:
|
||||
let
|
||||
base = baseNameOf (toString name);
|
||||
base = baseNameOf name;
|
||||
in
|
||||
type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
|
||||
in
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ let
|
|||
lib.listToAttrs (map mkEtcFile cfg.package.filesInstalledToEtc);
|
||||
extraTrustedKeys =
|
||||
let
|
||||
mkName = p: "pki/fwupd/${baseNameOf (toString p)}";
|
||||
mkName = p: "pki/fwupd/${baseNameOf p}";
|
||||
mkEtcFile = p: lib.nameValuePair (mkName p) { source = p; };
|
||||
in
|
||||
lib.listToAttrs (map mkEtcFile cfg.extraTrustedKeys);
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ in
|
|||
|
||||
stdenvNoCC.mkDerivation (
|
||||
{
|
||||
name = baseNameOf (toString src);
|
||||
name = baseNameOf src;
|
||||
}
|
||||
// optionalAttrs
|
||||
// forcedAttrs
|
||||
|
|
|
|||
|
|
@ -4347,7 +4347,7 @@ rec {
|
|||
sourceFilter =
|
||||
name: type:
|
||||
let
|
||||
baseName = baseNameOf (toString name);
|
||||
baseName = baseNameOf name;
|
||||
in
|
||||
!(
|
||||
# Filter out git
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
args:
|
||||
|
||||
let
|
||||
name = if args ? name then args.name else baseNameOf (toString args.src);
|
||||
name = args.name or (baseNameOf args.src);
|
||||
deprecationReplacement = lib.pipe args.replacements [
|
||||
lib.toList
|
||||
(map (lib.splitString " "))
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ let
|
|||
;
|
||||
src = monorepoSrc;
|
||||
versionDir =
|
||||
(toString ../.) + "/${if (gitRelease != null) then "git" else lib.versions.major release_version}";
|
||||
../. + "/${if (gitRelease != null) then "git" else lib.versions.major release_version}";
|
||||
getVersionFile =
|
||||
p:
|
||||
builtins.path {
|
||||
|
|
@ -95,15 +95,12 @@ let
|
|||
matchBefore && matchAfter;
|
||||
|
||||
patchDir =
|
||||
toString
|
||||
(
|
||||
if constraints == null then
|
||||
{ path = metadata.versionDir; }
|
||||
else
|
||||
(lib.findFirst matchConstraint { path = metadata.versionDir; } constraints)
|
||||
).path;
|
||||
if constraints == null then
|
||||
metadata.versionDir
|
||||
else
|
||||
(lib.findFirst matchConstraint { path = metadata.versionDir; } constraints).path;
|
||||
in
|
||||
"${patchDir}/${p}";
|
||||
patchDir + ("/" + p);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ let
|
|||
];
|
||||
resolvedLogoName =
|
||||
if (logoFile != null && logoName == null) then
|
||||
lib.strings.removeSuffix ".png" (baseNameOf (toString logoFile))
|
||||
lib.strings.removeSuffix ".png" (baseNameOf logoFile)
|
||||
else
|
||||
logoName;
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue