Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
base: 6b89e87a234c
Choose a base ref
...
head repository: NixOS/nixpkgs
compare: 4914a821868c
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Jul 19, 2019

  1. lib: allow sourceByRegex to be composed after cleanSourceWith

    `sourceByRegex src regexes` should include a source file if one of the
    regular expressions `regexes` matches the path of that file relative
    to `src`.
    
    However to compute this relative path `sourceByRegex` uses:
    
    ```
    relPath = lib.removePrefix (toString src + "/") (toString path);
    ```
    
    Note that `toString path` evaluates to an absolute file somewhere
    under `src` and not under `/nix/store`.
    
    The problem is that this doesn't work if `src` is a `cleanSourceWith`
    invocation as well because `toString src` will then evaluate to
    `src.outPath` which will evaluate to `builtins.filterSource ...` which
    evaluates to a path in `/nix/store` which is not a prefix of `path`.
    
    The solution is to replace `src` with `origSrc` where
    
    ```
    origSrc = if isFiltered then src.origSrc else src;
    isFiltered = src ? _isLibCleanSourceWith;
    ```
    
    Test this by executing the following from the nixpkgs repo:
    
    ```
    (cat << 'EOI'
    let
      pkgs = import ./. {};
    in pkgs.runCommand "test-sourceByRegex" {
      test_sourceByRegex =
        let
          src1 = pkgs.lib.sourceByRegex ./.  [ "^test-sourceByRegex.nix$" ];
          src2 = pkgs.lib.sourceByRegex src1 [ "^test-sourceByRegex.nix$" ];
        in src2 + "/test-sourceByRegex.nix";
    } ''
     cp $test_sourceByRegex $out
    ''
    EOI
    ) > test-sourceByRegex.nix
    nix-build test-sourceByRegex.nix
    ```
    basvandijk committed Jul 19, 2019
    Copy the full SHA
    58ea28e View commit details
    Browse the repository at this point in the history

Commits on Jul 25, 2019

  1. Merge pull request #65083 from basvandijk/fix-composability-of-source…

    …ByRegex
    
    lib: allow sourceByRegex to be composed after cleanSourceWith
    edolstra committed Jul 25, 2019
    Copy the full SHA
    4914a82 View commit details
    Browse the repository at this point in the history