lorri icon indicating copy to clipboard operation
lorri copied to clipboard

filterSource is not watched

Open symphorien opened this issue 5 years ago • 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.

symphorien avatar Jul 29 '20 16:07 symphorien

rc = filtersource fn ./. then ./. is not watched, because nix does not print copied source foo.

I don’t think that is the case, do you have a repro?

Profpatsch avatar Jul 29 '20 19:07 Profpatsch

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.

symphorien avatar Jul 29 '20 19:07 symphorien

Hm, can you reduce that to an example that only uses builltins.filterSource? I have spent hours trying to understand the nix-gitignore semantics, there’s so much going on there, it might as well be a bug in gitignoreSourcePure.

On Wed, Jul 29, 2020 at 9:31 PM symphorien [email protected] wrote:

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///archive/.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///archive/.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 ''; };inpkgs.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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/target/lorri/issues/455#issuecomment-665858792, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYB5ZSOZTWBOGWKDBXDOR3R6B2JFANCNFSM4PLYATLA .

Profpatsch avatar Jul 30 '20 15:07 Profpatsch

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.

symphorien avatar Aug 01 '20 13:08 symphorien