nixpkgs/lib
Bas van Dijk 58ea28eb2c 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
```
2019-07-19 16:23:11 +02:00
..
systems Revert "Revert "systems/doubles.nix: add Apple doubles"" 2019-07-10 15:14:59 -04:00
tests make-tarball / lib-tests: reduce duplication 2019-07-11 18:02:05 +02:00
asserts.nix lib: move assertMsg and assertOneOf to their own library file 2018-09-06 18:14:27 +02:00
attrsets.nix bundlerEnv: ensure dependencies always included 2018-12-11 21:26:07 +00:00
customisation.nix lib: tiny cleanup 2019-02-03 15:30:15 +00:00
debug.nix lib/debug: Update documentation comments for docs generation 2018-10-29 10:45:25 +01:00
default.nix check-meta: use system tuple in platforms 2019-04-30 12:59:03 -04:00
deprecated.nix lib: add shortcuts for fake hashes (fakeSha256, fakeSha512) 2019-01-10 19:27:35 +02:00
fetchers.nix
filesystem.nix
fixed-points.nix lib.converge: optimise 2019-04-17 15:55:57 +01:00
generators.nix treewide: Remove usage of isNull 2019-04-29 14:05:50 +02:00
kernel.nix linux: convert hardened-config to a structured one 2019-01-28 09:07:24 +09:00
licenses.nix licenses: refer to libpng2 using spdx 2019-06-12 22:04:52 +00:00
lists.nix lib: improve the implementation of the unique function 2019-04-12 20:08:29 +02:00
meta.nix lib: implement setPrio 2018-11-22 08:59:48 +00:00
minver.nix Nix minimal version: 1.11 -> 2.0 2018-08-30 08:09:54 -04:00
modules.nix module system: revert "remove types.optionSet", just deprecate (#56857) 2019-03-07 21:28:09 +02:00
options.nix module system: prettify a bit error when unique option defined twice 2019-06-05 03:10:57 +03:00
sources.nix lib: allow sourceByRegex to be composed after cleanSourceWith 2019-07-19 16:23:11 +02:00
strings-with-deps.nix
strings.nix Doc fix: use correct function name in type signature for concatIMapStringsSep 2019-03-18 12:14:39 +00:00
trivial.nix treewide: Remove usage of isNull 2019-04-29 14:05:50 +02:00
types.nix module system: revert "remove types.optionSet", just deprecate (#56857) 2019-03-07 21:28:09 +02:00
versions.nix
zip-int-bits.nix lib/trivial: move zipIntBits to its own file 2018-07-26 20:36:45 +02:00