mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-10 08:39:08 +03:00
lib,doc: remove obvious usages of toString on paths
It gives a warning on the lazy-trees branch of Nix (NixOS/nix#6530) one of these was also giving me an error (the one in lib/trivial probably) ``` $ nix build warning: applying 'toString' to path '/home/artturin/nixgits/my-nixpkgs/nixos/modules/installer/sd-card/sd -image-aarch64.nix' and then accessing it is deprecated, at /home/artturin/nixgits/my-nixpkgs/lib/modules. nix:349:99 warning: applying 'toString' to path '/home/artturin/nixgits/my-nixpkgs/.git' and then accessing it is dep recated, at /home/artturin/nixgits/my-nixpkgs/lib/sources.nix:35:32 warning: applying 'toString' to path '/home/artturin/nixgits/my-nixpkgs/nixos/modules/system/etc/etc.nix' and then accessing it is deprecated, at «stdin»:0 warning: applying 'toString' to path '/home/artturin/nixgits/my-nixpkgs/nixos/modules/system/etc/etc-activ ation.nix' and then accessing it is deprecated, at «stdin»:0 warning: applying 'toString' to path '/home/artturin/nixgits/my-nixpkgs/nixos/modules/installer/sd-card/sd -image-aarch64.nix' and then accessing it is deprecated, at «stdin»:0 error: cannot decode virtual path '/nix/store/virtual0000000000000000000000005-source' (use '--show-trace' to show detailed location information) ```
This commit is contained in:
parent
c4b49b957b
commit
66cf79f282
@ -38,7 +38,7 @@ let
|
|||||||
substr = builtins.substring prefixLen filenameLen filename;
|
substr = builtins.substring prefixLen filenameLen filename;
|
||||||
in substr;
|
in substr;
|
||||||
|
|
||||||
removeNixpkgs = removeFilenamePrefix (builtins.toString pkgs.path);
|
removeNixpkgs = removeFilenamePrefix pkgs.path;
|
||||||
|
|
||||||
liblocations =
|
liblocations =
|
||||||
builtins.filter
|
builtins.filter
|
||||||
|
@ -140,7 +140,7 @@ let
|
|||||||
origSrc = if isFiltered then src.origSrc else src;
|
origSrc = if isFiltered then src.origSrc else src;
|
||||||
in lib.cleanSourceWith {
|
in lib.cleanSourceWith {
|
||||||
filter = (path: type:
|
filter = (path: type:
|
||||||
let relPath = lib.removePrefix (toString origSrc + "/") (toString path);
|
let relPath = lib.removePrefix (origSrc + "/") (path);
|
||||||
in lib.any (re: match re relPath != null) regexes);
|
in lib.any (re: match re relPath != null) regexes);
|
||||||
inherit src;
|
inherit src;
|
||||||
};
|
};
|
||||||
@ -175,12 +175,12 @@ let
|
|||||||
*/
|
*/
|
||||||
commitIdFromGitRepo =
|
commitIdFromGitRepo =
|
||||||
let readCommitFromFile = file: path:
|
let readCommitFromFile = file: path:
|
||||||
let fileName = toString path + "/" + file;
|
let fileName = path + "/" + file;
|
||||||
packedRefsName = toString path + "/packed-refs";
|
packedRefsName = path + "/packed-refs";
|
||||||
absolutePath = base: path:
|
absolutePath = base: path:
|
||||||
if lib.hasPrefix "/" path
|
if lib.hasPrefix "/" path
|
||||||
then path
|
then path
|
||||||
else toString (/. + "${base}/${path}");
|
else /. + "${base}/${path}";
|
||||||
in if pathIsRegularFile path
|
in if pathIsRegularFile path
|
||||||
# Resolve git worktrees. See gitrepository-layout(5)
|
# Resolve git worktrees. See gitrepository-layout(5)
|
||||||
then
|
then
|
||||||
@ -226,7 +226,7 @@ let
|
|||||||
|
|
||||||
pathHasContext = builtins.hasContext or (lib.hasPrefix storeDir);
|
pathHasContext = builtins.hasContext or (lib.hasPrefix storeDir);
|
||||||
|
|
||||||
canCleanSource = src: src ? _isLibCleanSourceWith || !(pathHasContext (toString src));
|
canCleanSource = src: src ? _isLibCleanSourceWith || !(pathHasContext src);
|
||||||
|
|
||||||
# -------------------------------------------------------------------------- #
|
# -------------------------------------------------------------------------- #
|
||||||
# Internal functions
|
# Internal functions
|
||||||
|
@ -213,8 +213,8 @@ rec {
|
|||||||
# Default value to return if revision can not be determined
|
# Default value to return if revision can not be determined
|
||||||
default:
|
default:
|
||||||
let
|
let
|
||||||
revisionFile = "${toString ./..}/.git-revision";
|
revisionFile = ./.. + "/.git-revision";
|
||||||
gitRepo = "${toString ./..}/.git";
|
gitRepo = ./.. + "/.git";
|
||||||
in if lib.pathIsGitRepo gitRepo
|
in if lib.pathIsGitRepo gitRepo
|
||||||
then lib.commitIdFromGitRepo gitRepo
|
then lib.commitIdFromGitRepo gitRepo
|
||||||
else if lib.pathExists revisionFile then lib.fileContents revisionFile
|
else if lib.pathExists revisionFile then lib.fileContents revisionFile
|
||||||
|
Loading…
Reference in New Issue
Block a user