about summary refs log tree commit diff
path: root/lib/filesystem.nix
AgeCommit message (Collapse)AuthorFilesLines
2023-12-19lib.packagesFromDirectoryRecursive: initRebecca Turner1-0/+154
Co-authored-by: Gabriella Gonzalez <GenuineGabriella@gmail.com>
2023-11-20lib: Take advantage of section descriptionsSilvan Mosberger1-2/+4
See https://github.com/nix-community/nixdoc/releases/tag/v2.6.0
2023-06-23lib/filesystem: remove unused let bindingsfigsoda1-4/+0
2023-05-22lib/filesystem.nix: Update top commentSilvan Mosberger1-1/+3
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2023-05-22lib.filesystem.pathType: Use new builtins.readFileType if availableSilvan Mosberger1-11/+15
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2023-05-22lib.filesystem.pathType and co.: Improve documentationSilvan Mosberger1-3/+40
2023-05-22lib.filesystem.pathType: Improve error for non-existent pathsSilvan Mosberger1-1/+5
Previously it would fail with error: attribute 'nonexistent' missing at nixpkgs/lib/filesystem.nix:29:10: 28| if dirOf path == path then "directory" 29| else (readDir (dirOf path)).${baseNameOf path}; | ^ 30|
2023-05-22lib.filesystem.pathType: Fix for filesystem root argumentSilvan Mosberger1-1/+6
Previously this function couldn't handle / being passed, it would throw an error: error: attribute '' missing at nixpkgs/lib/filesystem.nix:24:20: 23| */ 24| pathType = path: (readDir (dirOf path)).${baseNameOf path}; | ^ 25| Consequently this also fixes the lib.filesystem.{pathIsDirectory,pathIsRegularFile} functions.
2023-05-22lib.filesystem: Minor refactorSilvan Mosberger1-4/+6
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
2023-04-05lib.sources.pathType and co.: Move to lib.filesystemSilvan Mosberger1-0/+26
These functions only work with the filesystem, they don't import anything as sources
2022-10-26lib: Automatically generate lib.filesytem docsSilvan Mosberger1-18/+40
2020-10-19lib: Add readTree function to filesystemFarid Zakaria1-0/+12
Add a friendly function to easily return a flattened list of files within a directory. This is useful if you want to easily iterate or concatSep the list of files all found within a directory. (i.e. when constructing Java's CLASSPATH) Style improvements Co-authored-by: Silvan Mosberger <github@infinisil.com>
2017-09-16Convert libs to a fixed-pointGraham Christensen1-0/+1
This does break the API of being able to import any lib file and get its libs, however I'm not sure people did this. I made this while exploring being able to swap out docFn with a stub in #2305, to avoid functor performance problems. I don't know if that is going to move forward (or if it is a problem or not,) but after doing all this work figured I'd put it up anyway :) Two notable advantages to this approach: 1. when a lib inherits another lib's functions, it doesn't automatically get put in to the scope of lib 2. when a lib implements a new obscure functions, it doesn't automatically get put in to the scope of lib Using the test script (later in this commit) I got the following diff on the API: + diff master fixed-lib 11764a11765,11766 > .types.defaultFunctor > .types.defaultTypeMerge 11774a11777,11778 > .types.isOptionType > .types.isType 11781a11786 > .types.mkOptionType 11788a11794 > .types.setType 11795a11802 > .types.types This means that this commit _adds_ to the API, however I can't find a way to fix these last remaining discrepancies. At least none are _removed_. Test script (run with nix-repl in the PATH): #!/bin/sh set -eux repl() { suff=${1:-} echo "(import ./lib)$suff" \ | nix-repl 2>&1 } attrs_to_check() { repl "${1:-}" \ | tr ';' $'\n' \ | grep "\.\.\." \ | cut -d' ' -f2 \ | sed -e "s/^/${1:-}./" \ | sort } summ() { repl "${1:-}" \ | tr ' ' $'\n' \ | sort \ | uniq } deep_summ() { suff="${1:-}" depth="${2:-4}" depth=$((depth - 1)) summ "$suff" for attr in $(attrs_to_check "$suff" | grep -v "types.types"); do if [ $depth -eq 0 ]; then summ "$attr" | sed -e "s/^/$attr./" else deep_summ "$attr" "$depth" | sed -e "s/^/$attr./" fi done } ( cd nixpkgs #git add . #git commit -m "Auto-commit, sorry" || true git checkout fixed-lib deep_summ > ../fixed-lib git checkout master deep_summ > ../master ) if diff master fixed-lib; then echo "SHALLOW MATCH!" fi ( cd nixpkgs git checkout fixed-lib repl .types )
2017-05-01Add haskellPathsInDir lib functionShea Levy1-1/+19
2017-03-04Add locateDominatingFile lib functionShea Levy1-0/+26