Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib,doc: remove obvious usages of toString on paths #199772

Merged
merged 1 commit into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/doc-support/lib-function-locations.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let
substr = builtins.substring prefixLen filenameLen filename;
in substr;

removeNixpkgs = removeFilenamePrefix (builtins.toString pkgs.path);
removeNixpkgs = removeFilenamePrefix pkgs.path;

liblocations =
builtins.filter
Expand Down
10 changes: 5 additions & 5 deletions lib/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ let
origSrc = if isFiltered then src.origSrc else src;
in lib.cleanSourceWith {
filter = (path: type:
let relPath = lib.removePrefix (toString origSrc + "/") (toString path);
let relPath = lib.removePrefix (origSrc + "/") (path);
Copy link
Member

@ncfavier ncfavier Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

removePrefix doesn't work on paths, does it? Won't this copy every single path to the store?

EDIT: ah, this was reverted

in lib.any (re: match re relPath != null) regexes);
inherit src;
};
Expand Down Expand Up @@ -175,12 +175,12 @@ let
*/
commitIdFromGitRepo =
let readCommitFromFile = file: path:
let fileName = toString path + "/" + file;
packedRefsName = toString path + "/packed-refs";
let fileName = path + "/" + file;
packedRefsName = path + "/packed-refs";
absolutePath = base: path:
if lib.hasPrefix "/" path
then path
else toString (/. + "${base}/${path}");
else /. + "${base}/${path}";
in if pathIsRegularFile path
# Resolve git worktrees. See gitrepository-layout(5)
then
Expand Down Expand Up @@ -226,7 +226,7 @@ let

pathHasContext = builtins.hasContext or (lib.hasPrefix storeDir);

canCleanSource = src: src ? _isLibCleanSourceWith || !(pathHasContext (toString src));
canCleanSource = src: src ? _isLibCleanSourceWith || !(pathHasContext src);

# -------------------------------------------------------------------------- #
# Internal functions
Expand Down
4 changes: 2 additions & 2 deletions lib/trivial.nix
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ rec {
# Default value to return if revision can not be determined
default:
let
revisionFile = "${toString ./..}/.git-revision";
gitRepo = "${toString ./..}/.git";
revisionFile = ./.. + "/.git-revision";
gitRepo = ./.. + "/.git";
in if lib.pathIsGitRepo gitRepo
then lib.commitIdFromGitRepo gitRepo
else if lib.pathExists revisionFile then lib.fileContents revisionFile
Expand Down