treewide: remove optional builtins prefixes from prelude functions

Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd --type file --exec-batch sed --in-place --regexp-extended "
      s/\<builtins\.($(
        printf '%s\n' "${builtins[@]}" |
          paste --delimiter '|' --serial -
      ))\>/\1/g
    "

    nix fmt
This commit is contained in:
NAHO
2025-09-30 08:50:13 +02:00
parent d17f0c1bf8
commit dec908b169
9 changed files with 22 additions and 22 deletions

View File

@@ -22,7 +22,7 @@ let
anyMatchingFiles = files: builtins.any anyMatchingFile files; anyMatchingFiles = files: builtins.any anyMatchingFile files;
attrsWithMaintainers = lib.pipe (changedattrs ++ removedattrs) [ attrsWithMaintainers = lib.pipe (changedattrs ++ removedattrs) [
(builtins.map ( (map (
name: name:
let let
# Some packages might be reported as changed on a different platform, but # Some packages might be reported as changed on a different platform, but
@@ -46,7 +46,7 @@ let
relevantFilenames = relevantFilenames =
drv: drv:
(lib.lists.unique ( (lib.lists.unique (
builtins.map (pos: lib.strings.removePrefix (toString ../..) pos.file) ( map (pos: lib.strings.removePrefix (toString ../..) pos.file) (
builtins.filter (x: x != null) [ builtins.filter (x: x != null) [
((drv.meta or { }).maintainersPosition or null) ((drv.meta or { }).maintainersPosition or null)
((drv.meta or { }).teamsPosition or null) ((drv.meta or { }).teamsPosition or null)
@@ -73,7 +73,7 @@ let
) )
)); ));
attrsWithFilenames = builtins.map ( attrsWithFilenames = map (
pkg: pkg // { filenames = relevantFilenames pkg.package; } pkg: pkg // { filenames = relevantFilenames pkg.package; }
) attrsWithMaintainers; ) attrsWithMaintainers;
@@ -81,7 +81,7 @@ let
listToPing = lib.concatMap ( listToPing = lib.concatMap (
pkg: pkg:
builtins.map (maintainer: { map (maintainer: {
id = maintainer.githubId; id = maintainer.githubId;
inherit (maintainer) github; inherit (maintainer) github;
packageName = pkg.name; packageName = pkg.name;
@@ -92,7 +92,7 @@ let
byMaintainer = lib.groupBy (ping: toString ping.${if byName then "github" else "id"}) listToPing; byMaintainer = lib.groupBy (ping: toString ping.${if byName then "github" else "id"}) listToPing;
packagesPerMaintainer = lib.attrsets.mapAttrs ( packagesPerMaintainer = lib.attrsets.mapAttrs (
maintainer: packages: builtins.map (pkg: pkg.packageName) packages maintainer: packages: map (pkg: pkg.packageName) packages
) byMaintainer; ) byMaintainer;
in in
packagesPerMaintainer packagesPerMaintainer

View File

@@ -66,7 +66,7 @@ rec {
*/ */
convertToPackagePlatformAttrs = convertToPackagePlatformAttrs =
packagePlatformPaths: packagePlatformPaths:
builtins.filter (x: x != null) (builtins.map convertToPackagePlatformAttr packagePlatformPaths); builtins.filter (x: x != null) (map convertToPackagePlatformAttr packagePlatformPaths);
/* /*
Converts a list of `packagePlatformPath`s directly to a list of (unique) package names Converts a list of `packagePlatformPath`s directly to a list of (unique) package names
@@ -91,7 +91,7 @@ rec {
let let
packagePlatformAttrs = convertToPackagePlatformAttrs (uniqueStrings packagePlatformPaths); packagePlatformAttrs = convertToPackagePlatformAttrs (uniqueStrings packagePlatformPaths);
in in
uniqueStrings (builtins.map (p: p.name) packagePlatformAttrs); uniqueStrings (map (p: p.name) packagePlatformAttrs);
/* /*
Group a list of `packagePlatformAttr`s by platforms Group a list of `packagePlatformAttr`s by platforms

View File

@@ -95,7 +95,7 @@ let
in in
tweak ( tweak (
(builtins.removeAttrs nixpkgsJobs blacklist) (removeAttrs nixpkgsJobs blacklist)
// { // {
nixosTests.simple = nixosJobs.tests.simple; nixosTests.simple = nixosJobs.tests.simple;
} }

View File

@@ -91,7 +91,7 @@
) )
]; ];
} }
// builtins.removeAttrs args [ "modules" ] // removeAttrs args [ "modules" ]
); );
} }
); );

View File

@@ -8,7 +8,7 @@ rustPlatform.buildRustPackage {
filter = filter =
name: type: name: type:
let let
name' = builtins.baseNameOf name; name' = baseNameOf name;
in in
name' != "default.nix" && name' != "target"; name' != "default.nix" && name' != "target";
}; };

View File

@@ -65,7 +65,7 @@ let
inherit (pkgs) lib; inherit (pkgs) lib;
# see usage explanation for the input format `files` allows # see usage explanation for the input format `files` allows
files' = builtins.map builtins.baseNameOf (if !builtins.isList files then [ files ] else files); files' = map baseNameOf (if !builtins.isList files then [ files ] else files);
packageSetsWithVersionedHead = packageSetsWithVersionedHead =
pkgs.haskell.packages pkgs.haskell.packages
@@ -99,7 +99,7 @@ let
# match the major and minor version of the GHC the config is intended for, if any # match the major and minor version of the GHC the config is intended for, if any
configVersion = lib.concatStrings (builtins.match "ghc-([0-9]+).([0-9]+).x" configName); configVersion = lib.concatStrings (builtins.match "ghc-([0-9]+).([0-9]+).x" configName);
# return all package sets under haskell.packages matching the version components # return all package sets under haskell.packages matching the version components
setsForVersion = builtins.map (name: packageSetsWithVersionedHead.${name}) ( setsForVersion = map (name: packageSetsWithVersionedHead.${name}) (
builtins.filter ( builtins.filter (
setName: setName:
lib.hasPrefix "ghc${configVersion}" setName && (skipBinaryGHCs -> !(lib.hasInfix "Binary" setName)) lib.hasPrefix "ghc${configVersion}" setName && (skipBinaryGHCs -> !(lib.hasInfix "Binary" setName))
@@ -120,7 +120,7 @@ let
# attribute set that has all the attributes of haskellPackages set to null # attribute set that has all the attributes of haskellPackages set to null
availableHaskellPackages = builtins.listToAttrs ( availableHaskellPackages = builtins.listToAttrs (
builtins.map (attr: lib.nameValuePair attr null) (builtins.attrNames pkgs.haskellPackages) map (attr: lib.nameValuePair attr null) (builtins.attrNames pkgs.haskellPackages)
); );
# evaluate a configuration and only return the attributes changed by it, # evaluate a configuration and only return the attributes changed by it,
@@ -155,7 +155,7 @@ let
sets = setsForFile fileName; sets = setsForFile fileName;
attrs = overriddenAttrs fileName; attrs = overriddenAttrs fileName;
in in
lib.concatMap (set: builtins.map (attr: set.${attr}) attrs) sets lib.concatMap (set: map (attr: set.${attr}) attrs) sets
) files' ) files'
); );
in in

View File

@@ -69,7 +69,7 @@ nixexpr() {
]; ];
in in
tweak (builtins.removeAttrs hydraJobs blacklist) tweak (removeAttrs hydraJobs blacklist)
EONIX EONIX
} }

View File

@@ -120,7 +120,7 @@ let
let let
maintainer = maintainer =
if !builtins.hasAttr maintainer' lib.maintainers then if !builtins.hasAttr maintainer' lib.maintainers then
builtins.throw "Maintainer with name `${maintainer'} does not exist in `maintainers/maintainer-list.nix`." throw "Maintainer with name `${maintainer'} does not exist in `maintainers/maintainer-list.nix`."
else else
builtins.getAttr maintainer' lib.maintainers; builtins.getAttr maintainer' lib.maintainers;
in in
@@ -147,7 +147,7 @@ let
pathContent = lib.attrByPath prefix null pkgs; pathContent = lib.attrByPath prefix null pkgs;
in in
if pathContent == null then if pathContent == null then
builtins.throw "Attribute path `${path}` does not exist." throw "Attribute path `${path}` does not exist."
else else
packagesWithPath prefix (path: pkg: (get-script pkg != null)) pathContent; packagesWithPath prefix (path: pkg: (get-script pkg != null)) pathContent;
@@ -158,9 +158,9 @@ let
package = lib.attrByPath (lib.splitString "." path) null pkgs; package = lib.attrByPath (lib.splitString "." path) null pkgs;
in in
if package == null then if package == null then
builtins.throw "Package with an attribute name `${path}` does not exist." throw "Package with an attribute name `${path}` does not exist."
else if get-script package == null then else if get-script package == null then
builtins.throw "Package with an attribute name `${path}` does not have a `passthru.updateScript` attribute defined." throw "Package with an attribute name `${path}` does not have a `passthru.updateScript` attribute defined."
else else
{ {
attrPath = path; attrPath = path;
@@ -178,7 +178,7 @@ let
else if path != null then else if path != null then
packagesWithUpdateScript path pkgs packagesWithUpdateScript path pkgs
else else
builtins.throw "No arguments provided.\n\n${helpText}"; throw "No arguments provided.\n\n${helpText}";
helpText = '' helpText = ''
Please run: Please run:
@@ -242,7 +242,7 @@ let
name = package.name; name = package.name;
pname = lib.getName package; pname = lib.getName package;
oldVersion = lib.getVersion package; oldVersion = lib.getVersion package;
updateScript = map builtins.toString (lib.toList (updateScript.command or updateScript)); updateScript = map toString (lib.toList (updateScript.command or updateScript));
supportedFeatures = updateScript.supportedFeatures or [ ]; supportedFeatures = updateScript.supportedFeatures or [ ];
attrPath = updateScript.attrPath or attrPath; attrPath = updateScript.attrPath or attrPath;
}; };

View File

@@ -19,7 +19,7 @@ let
inherit (import ./ci { inherit nixpkgs system; }) pkgs fmt; inherit (import ./ci { inherit nixpkgs system; }) pkgs fmt;
# For `nix-shell -A hello` # For `nix-shell -A hello`
curPkgs = builtins.removeAttrs (import ./. { inherit system; }) [ curPkgs = removeAttrs (import ./. { inherit system; }) [
# Although this is what anyone may expect from a `_type = "pkgs"`, # Although this is what anyone may expect from a `_type = "pkgs"`,
# this file is intended to produce a shell in the first place, # this file is intended to produce a shell in the first place,
# and a `_type` tag could confuse some code. # and a `_type` tag could confuse some code.