query
On this page

readPathsFromFile

lib.strings.readPathsFromFile

Docs pulled from | This Revision | about 3 hours ago


Read a list of paths from file, relative to the rootPath. Lines beginning with # are treated as comments and ignored. Whitespace is significant.

This function is deprecated and should be avoided.

This function is not performant and should be avoided.

Inputs

rootPath
1. Function argument
file
2. Function argument

Type

readPathsFromFile :: string -> string -> [string]

Examples

lib.strings.readPathsFromFile usage example

readPathsFromFile /prefix
  ./pkgs/development/libraries/qt-5/5.4/qtbase/series
=> [ "/prefix/dlopen-resolv.patch" "/prefix/tzdir.patch"
     "/prefix/dlopen-libXcursor.patch" "/prefix/dlopen-openssl.patch"
     "/prefix/dlopen-dbus.patch" "/prefix/xdg-config-dirs.patch"
     "/prefix/nix-profiles-library-paths.patch"
     "/prefix/compose-search-path.patch" ]

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

readPathsFromFile = lib.warn "lib.readPathsFromFile is deprecated, use a list instead."
    (rootPath: file:
      let
        lines = lib.splitString "\n" (readFile file);
        removeComments = lib.filter (line: line != "" && !(lib.hasPrefix "#" line));
        relativePaths = removeComments lines;
        absolutePaths = map (path: rootPath + "/${path}") relativePaths;
      in
        absolutePaths);