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

Improvements to pathType, pathIsDirectory and pathIsRegularFile #224834

Merged
merged 8 commits into from
May 23, 2023

Commits on Apr 5, 2023

  1. lib.sources.pathType and co.: Move to lib.filesystem

    These functions only work with the filesystem, they don't import
    anything as sources
    infinisil committed Apr 5, 2023
    Configuration menu
    Copy the full SHA
    c701a4d View commit details
    Browse the repository at this point in the history

Commits on May 22, 2023

  1. lib.filesystem.pathType and co.: Add tests

    Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
    infinisil and roberth committed May 22, 2023
    Configuration menu
    Copy the full SHA
    a1dedc9 View commit details
    Browse the repository at this point in the history
  2. lib.filesystem: Minor refactor

    Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
    infinisil and roberth committed May 22, 2023
    Configuration menu
    Copy the full SHA
    5346636 View commit details
    Browse the repository at this point in the history
  3. lib.filesystem.pathType: Fix for filesystem root argument

    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.
    infinisil committed May 22, 2023
    Configuration menu
    Copy the full SHA
    bb6eab0 View commit details
    Browse the repository at this point in the history
  4. lib.filesystem.pathType: Improve error for non-existent paths

    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|
    infinisil committed May 22, 2023
    Configuration menu
    Copy the full SHA
    d064d97 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    84a3d63 View commit details
    Browse the repository at this point in the history
  6. lib.filesystem.pathType: Use new builtins.readFileType if available

    Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
    infinisil and roberth committed May 22, 2023
    Configuration menu
    Copy the full SHA
    fcaa2b1 View commit details
    Browse the repository at this point in the history
  7. lib/filesystem.nix: Update top comment

    Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
    infinisil and roberth committed May 22, 2023
    Configuration menu
    Copy the full SHA
    378bf1a View commit details
    Browse the repository at this point in the history