Go to file
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
.github Update FUNDING.yml 2019-07-17 14:22:24 +02:00
doc Merge master into staging-next 2019-07-13 09:45:40 +02:00
lib lib: allow sourceByRegex to be composed after cleanSourceWith 2019-07-19 16:23:11 +02:00
maintainers Change maintainter's name 2019-07-19 09:21:18 +02:00
nixos nixos/doc: fix build 2019-07-18 20:40:24 -04:00
pkgs gnome3.gnome-getting-started-docs: 3.32.1 -> 3.32.2 (#65073) 2019-07-19 14:45:17 +02:00
.editorconfig Revert ".version: remove final newline" 2018-04-28 14:23:13 +02:00
.gitattributes gitattributes: disable merge=union in all-packages 2018-03-27 11:03:03 -05:00
.gitignore Replace androidenv by new implementation 2018-12-18 21:16:06 +01:00
.version 19.09 is Loris. 2019-02-25 23:21:14 +01:00
COPYING COPYING: include 2019 2019-03-18 19:55:33 -07:00
default.nix Fix local path to release notes in error message 2018-10-08 05:43:15 -05:00
README.md README: add open collective badge 2019-07-17 14:27:28 +02:00

logo

Code Triagers Badge Open Collective supporters

Nixpkgs is a collection of packages for the Nix package manager. It is periodically built and tested by the Hydra build daemon as so-called channels. To get channel information via git, add nixpkgs-channels as a remote:

% git remote add channels https://github.com/NixOS/nixpkgs-channels.git

For stability and maximum binary package support, it is recommended to maintain custom changes on top of one of the channels, e.g. nixos-19.03 for the latest release and nixos-unstable for the latest successful build of master:

% git remote update channels
% git rebase channels/nixos-19.03

For pull requests, please rebase onto nixpkgs master.

NixOS Linux distribution source code is located inside nixos/ folder.

Communication:

Note: MIT license does not apply to the packages built by Nixpkgs, merely to the package descriptions (Nix expressions, build scripts, and so on). It also might not apply to patches included in Nixpkgs, which may be derivative works of the packages to which they apply. The aforementioned artifacts are all covered by the licenses of the respective packages.