filterSource is not watched
Opened this issue · 4 comments
if one of the buildInputs of a shell.nix has src = filtersource fn ./.
then ./.
is not watched, because nix does not print copied source foo
.
This is fixed by
diff --git a/src/logged-evaluation.nix b/src/logged-evaluation.nix
index c1d5b9d..ded6f5a 100644
--- a/src/logged-evaluation.nix
+++ b/src/logged-evaluation.nix
@@ -13,6 +13,7 @@ let
builtins = builtins // {
readFile = file: builtins.trace "lorri read: '${toString file}'" (builtins.readFile file);
readDir = path: builtins.trace "lorri read: '${toString path}'" (builtins.readDir path);
+ filterSource = fn: path: builtins.trace "lorri read: '${toString path}'" (builtins.filterSource fn path);
};
};
but for a reason I ignore this causes many (approx 5) rebuilds for only one changed files.
Note that it also applies to nix-gitignore that you recommend in your readme.
rc = filtersource fn ./.
then./.
is not watched, because nix does not printcopied source foo
.
I don’t think that is the case, do you have a repro?
b/nix/sources.json
{
"niv": {
"branch": "master",
"description": "Easy dependency management for Nix projects",
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "ab9cc41caf44d1f1d465d8028e4bc0096fd73238",
"sha256": "17k52n8zwp832cqifsc4458mhy4044wmk22f807171hf6p7l4xvr",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/ab9cc41caf44d1f1d465d8028e4bc0096fd73238.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-19.09",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs-channels",
"rev": "289466dd6a11c65a7de4a954d6ebf66c1ad07652",
"sha256": "0r5ja052s86fr54fm1zlhld3fwawz2w1d1gd6vbvpjrpjfyajibn",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/289466dd6a11c65a7de4a954d6ebf66c1ad07652.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"other": {
"path": "/home/symphorien/src/a",
"sha256": "0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73",
"type": "local",
"url": "file:///home/symphorien/src/a",
"url_template": "file:///home/symphorien/src/a"
}
}
b/shell.nix:
let
sources = import nix/sources.nix {};
pkgs = import sources.nixpkgs {};
niv = (import sources.niv {}).niv;
other_repo = pkgs.stdenv.mkDerivation {
name = "foo";
src = pkgs.nix-gitignore.gitignoreSourcePure [""] (/. + sources.other);
dontUnpack = true;
installPhase = ''
mkdir -p $out/bin
cp $src/foo $out/bin
echo "cat $out/bin/foo" > $out/bin/version
chmod +x $out/bin/version
'';
};
in
pkgs.mkShell {
buildInputs = [ other_repo niv ];
}
and create a file a/foo
If you change the content of a/foo
then lorri does not pick it up and rebuild.
And nix-instantiate -vv b/shell.nix |& grep "copied source '/home"
says nothing.
Minimized:
b/shell.nix
let
pkgs = import <nixpkgs> {};
other_repo = pkgs.stdenv.mkDerivation {
name = "foo";
src = builtins.filterSource (_: _: true) (../a);
dontUnpack = true;
installPhase = ''
mkdir -p $out/bin
cp $src/foo $out/bin
echo "cat $out/bin/foo" > $out/bin/version
chmod +x $out/bin/version
'';
};
in
pkgs.mkShell {
buildInputs = [ other_repo ];
}
change a/foo and observe that lorri does not rebuild.