From 6da6accd303be776bb4e958da52046da86f9cb5c Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 22 May 2018 16:42:02 -0400 Subject: treewide: Remove uses of builtins.toPath. toPath has confusing semantics and is never necessary; it can always either just be omitted or replaced by pre-concatenating `/.`. It has been marked as "!!! obsolete?" for more than 10 years in a C++ comment, hopefully removing it will let us properly deprecate and, eventually, remove it. --- lib/strings.nix | 5 ++--- lib/tests/misc.nix | 4 ++-- nixos/lib/eval-config.nix | 2 +- nixos/modules/services/x11/desktop-managers/enlightenment.nix | 2 +- pkgs/build-support/fetchdocker/default.nix | 4 ++-- pkgs/development/mobile/androidenv/androidndk.nix | 2 +- .../darwin/apple-source-releases/libsecurity_generic/default.nix | 2 +- pkgs/servers/bird/default.nix | 2 +- pkgs/servers/monitoring/telegraf/default.nix | 2 +- pkgs/servers/nosql/influxdb/default.nix | 2 +- pkgs/tools/typesetting/tex/texlive/combine.nix | 2 +- 11 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/strings.nix b/lib/strings.nix index e09ec42bfea23..2a61b1465cc28 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -492,7 +492,7 @@ rec { isStorePath = x: isCoercibleToString x && builtins.substring 0 1 (toString x) == "/" - && dirOf (builtins.toPath x) == builtins.storeDir; + && dirOf x == builtins.storeDir; /* Convert string to int Obviously, it is a bit hacky to use fromJSON that way. @@ -528,11 +528,10 @@ rec { */ readPathsFromFile = rootPath: file: let - root = toString rootPath; lines = lib.splitString "\n" (builtins.readFile file); removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line)); relativePaths = removeComments lines; - absolutePaths = builtins.map (path: builtins.toPath (root + "/" + path)) relativePaths; + absolutePaths = builtins.map (path: rootPath + "/${path}") relativePaths; in absolutePaths; diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index c683df7d7ca3b..c0e1aaa248ebb 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -97,7 +97,7 @@ runTests { storePathAppendix = isStorePath "${goodPath}/bin/python"; nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath))); - asPath = isStorePath (builtins.toPath goodPath); + asPath = isStorePath goodPath; otherPath = isStorePath "/something/else"; otherVals = { attrset = isStorePath {}; @@ -318,7 +318,7 @@ runTests { int = 42; bool = true; string = ''fno"rd''; - path = /. + "/foo"; # toPath returns a string + path = /. + "/foo"; null_ = null; function = x: x; functionArgs = { arg ? 4, foo }: arg; diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix index 97c79487df4c1..d005fc61dc4e7 100644 --- a/nixos/lib/eval-config.nix +++ b/nixos/lib/eval-config.nix @@ -28,7 +28,7 @@ let extraArgs_ = extraArgs; pkgs_ = pkgs; extraModules = let e = builtins.getEnv "NIXOS_EXTRA_MODULE_PATH"; - in if e == "" then [] else [(import (builtins.toPath e))]; + in if e == "" then [] else [(import e)]; in let diff --git a/nixos/modules/services/x11/desktop-managers/enlightenment.nix b/nixos/modules/services/x11/desktop-managers/enlightenment.nix index da3287aaea6ec..5c083a151ff3f 100644 --- a/nixos/modules/services/x11/desktop-managers/enlightenment.nix +++ b/nixos/modules/services/x11/desktop-managers/enlightenment.nix @@ -61,7 +61,7 @@ in ''; }]; - security.wrappers = (import (builtins.toPath "${e.enlightenment}/e-wrappers.nix")).security.wrappers; + security.wrappers = (import "${e.enlightenment}/e-wrappers.nix").security.wrappers; environment.etc = singleton { source = xcfg.xkbDir; diff --git a/pkgs/build-support/fetchdocker/default.nix b/pkgs/build-support/fetchdocker/default.nix index ae3ae4185e053..b54e4141afc93 100644 --- a/pkgs/build-support/fetchdocker/default.nix +++ b/pkgs/build-support/fetchdocker/default.nix @@ -22,8 +22,8 @@ assert null == lib.findFirst (c: "/"==c) null (lib.stringToCharacters repository assert null == lib.findFirst (c: "/"==c) null (lib.stringToCharacters imageName); let - # Abuse `builtins.toPath` to collapse possible double slashes - repoTag0 = builtins.toString (builtins.toPath "/${stripScheme registry}/${repository}/${imageName}"); + # Abuse paths to collapse possible double slashes + repoTag0 = builtins.toString (/. + "/${stripScheme registry}/${repository}/${imageName}"); repoTag1 = lib.removePrefix "/" repoTag0; layers = builtins.map stripNixStore imageLayers; diff --git a/pkgs/development/mobile/androidenv/androidndk.nix b/pkgs/development/mobile/androidenv/androidndk.nix index 78e278be2376e..1c0f75215e76f 100644 --- a/pkgs/development/mobile/androidenv/androidndk.nix +++ b/pkgs/development/mobile/androidenv/androidndk.nix @@ -50,7 +50,7 @@ stdenv.mkDerivation rec { patch -p1 \ --no-backup-if-mismatch \ - -d $out/libexec/${name} < ${ ./. + builtins.toPath ("/make_standalone_toolchain.py_" + "${version}" + ".patch") } + -d $out/libexec/${name} < ${ ./. + "/make_standalone_toolchain.py_${version}.patch" } wrapProgram ${pkg_path}/build/tools/make_standalone_toolchain.py --prefix PATH : "${runtime_paths}" '' } diff --git a/pkgs/os-specific/darwin/apple-source-releases/libsecurity_generic/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libsecurity_generic/default.nix index 93857ea792c25..2efdc5abeb31d 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libsecurity_generic/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libsecurity_generic/default.nix @@ -1,7 +1,7 @@ { appleDerivation_, applePackage, pkgs, stdenv }: name: version: sha256: args: let n = stdenv.lib.removePrefix "lib" name; - makeFile = ../. + builtins.toPath "/${name}/GNUmakefile"; + makeFile = ../. + "/${name}/GNUmakefile"; appleDerivation = appleDerivation_ name version sha256; in applePackage name version sha256 (args // { appleDerivation = a: diff --git a/pkgs/servers/bird/default.nix b/pkgs/servers/bird/default.nix index 94bd92abb4f87..f44ae83ec03a3 100644 --- a/pkgs/servers/bird/default.nix +++ b/pkgs/servers/bird/default.nix @@ -17,7 +17,7 @@ let buildInputs = [ readline ]; patches = [ - (./. + (builtins.toPath "/dont-create-sysconfdir-${builtins.substring 0 1 version}.patch")) + (./. + "/dont-create-sysconfdir-${builtins.substring 0 1 version}.patch") ]; configureFlags = [ diff --git a/pkgs/servers/monitoring/telegraf/default.nix b/pkgs/servers/monitoring/telegraf/default.nix index b7879cc763aa7..dc219416fcb9e 100644 --- a/pkgs/servers/monitoring/telegraf/default.nix +++ b/pkgs/servers/monitoring/telegraf/default.nix @@ -19,7 +19,7 @@ buildGoPackage rec { -X main.version=${version} '' ]; - goDeps = ./. + builtins.toPath "/deps-${version}.nix"; + goDeps = ./. + "/deps-${version}.nix"; meta = with lib; { description = "The plugin-driven server agent for collecting & reporting metrics."; diff --git a/pkgs/servers/nosql/influxdb/default.nix b/pkgs/servers/nosql/influxdb/default.nix index 972bd53d95ee6..466bf6a60a066 100644 --- a/pkgs/servers/nosql/influxdb/default.nix +++ b/pkgs/servers/nosql/influxdb/default.nix @@ -20,7 +20,7 @@ buildGoPackage rec { excludedPackages = "test"; # Generated with the nix2go - goDeps = ./. + builtins.toPath "/deps-${version}.nix"; + goDeps = ./. + "/deps-${version}.nix"; meta = with lib; { description = "An open-source distributed time series database"; diff --git a/pkgs/tools/typesetting/tex/texlive/combine.nix b/pkgs/tools/typesetting/tex/texlive/combine.nix index 35fee64ba54f4..f1a20552d3824 100644 --- a/pkgs/tools/typesetting/tex/texlive/combine.nix +++ b/pkgs/tools/typesetting/tex/texlive/combine.nix @@ -35,7 +35,7 @@ let mkUniquePkgs = pkgs: fastUnique (a: b: a < b) # highlighting hack: > # here we deal with those dummy packages needed for hyphenation filtering - (map (p: if lib.isDerivation p then builtins.toPath p else "") pkgs); + (map (p: if lib.isDerivation p then p.outPath else "") pkgs); in buildEnv { name = "texlive-${extraName}-${bin.texliveYear}"; -- cgit 1.4.1