After @dudebout solved my problem in #6 of it watching too many paths, I'm encountering the opposite problem: it doesn't watch all paths it should.
A simple example:
let
pkgs = import <nixpkgs> {};
deps = pkgs.stdenv.mkDerivation {
name = "deps";
src = builtins.filterSource (path: type: baseNameOf path == "pkg") ./.;
installPhase = ''
echo "pkgs: with pkgs; [ $(cat pkg) ]" > $out
'';
};
in pkgs.stdenv.mkDerivation {
name = "test";
nativeBuildInputs = import deps pkgs;
}
This uses import-from-derivation (IFD) by first building a derivation for knowing the dependencies, depending on a file ./pkg
through builtins.filterSource
(touch
that file), then puts those dependencies in the build inputs. Lorri ends up not watching the file, as seen from the log:
[2019-04-01T01:01:22Z DEBUG lorri] Input options: Arguments { verbosity: 0, command: Watch }
Started
[2019-04-01T01:01:22Z DEBUG lorri::build_loop] original paths: 518
[2019-04-01T01:01:22Z DEBUG lorri::build_loop] -> reduced to: 3
[2019-04-01T01:01:22Z DEBUG lorri::build_loop] named drvs: {
"shell": "/nix/store/gc1303z31vq35sl044fxfk0z9pmdkg42-test.drv",
"shell_gc_root": "/nix/store/vl1rb2fsk4f50p5d6h2qsqj8iin86b20-lorri-keep-env-hack-test.drv"
}
[2019-04-01T01:01:22Z DEBUG lorri::roots] Adding root from "/nix/store/gc1303z31vq35sl044fxfk0z9pmdkg42-test.drv" to "/home/infinisil/.cache/lorri/lorri/gc_root/attr-shell"
[2019-04-01T01:01:22Z DEBUG lorri::roots] Connecting root from "/home/infinisil/.cache/lorri/lorri/gc_root/attr-shell" to "/nix/var/nix/gcroots/per-user/infinisil/1aaab9fec1be4998a934b77cbe8194b8-ff9d02677be05e0746001cc0ed1ec807-attr-shell"
[2019-04-01T01:01:22Z DEBUG lorri::roots] Adding root from "/nix/store/vl1rb2fsk4f50p5d6h2qsqj8iin86b20-lorri-keep-env-hack-test.drv" to "/home/infinisil/.cache/lorri/lorri/gc_root/attr-shell_gc_root"
[2019-04-01T01:01:22Z DEBUG lorri::roots] Connecting root from "/home/infinisil/.cache/lorri/lorri/gc_root/attr-shell_gc_root" to "/nix/var/nix/gcroots/per-user/infinisil/1aaab9fec1be4998a934b77cbe8194b8-ff9d02677be05e0746001cc0ed1ec807-attr-shell_gc_root"
[2019-04-01T01:01:22Z DEBUG lorri::roots] Adding root from "/nix/store/s11p9yzvbiff29m1qr30kk7hpcgij5cl-lorri-keep-env-hack-test" to "/home/infinisil/.cache/lorri/lorri/gc_root/build-0"
[2019-04-01T01:01:22Z DEBUG lorri::roots] Connecting root from "/home/infinisil/.cache/lorri/lorri/gc_root/build-0" to "/nix/var/nix/gcroots/per-user/infinisil/1aaab9fec1be4998a934b77cbe8194b8-ff9d02677be05e0746001cc0ed1ec807-build-0"
[2019-04-01T01:01:22Z DEBUG lorri::watch] Watching path "/home/infinisil/Test/lorri/shell.nix"
[2019-04-01T01:01:22Z DEBUG lorri::watch] Watching parent path "/home/infinisil/Test/lorri"
[2019-04-01T01:01:22Z DEBUG lorri::watch] Watching path "/home/infinisil/.config/nixpkgs/config.nix"
[2019-04-01T01:01:22Z DEBUG lorri::watch] Watching parent path "/home/infinisil/.config/nixpkgs"
[2019-04-01T01:01:22Z DEBUG lorri::watch] Watching path "/home/infinisil/.config/nixpkgs/overlays"
[2019-04-01T01:01:22Z DEBUG lorri::watch] Watching parent path "/home/infinisil/.config/nixpkgs"
Completed(
BuildResults {
drvs: {
0: "/home/infinisil/.cache/lorri/lorri/gc_root/build-0"
},
named_drvs: {
"shell": "/home/infinisil/.cache/lorri/lorri/gc_root/attr-shell",
"shell_gc_root": "/home/infinisil/.cache/lorri/lorri/gc_root/attr-shell_gc_root"
}
}
)
Meaning I can change the contents of the file ./pkg
, which would have an influence on nix-shell
, but lorri doesn't budge. And because there's no way to either forcefully include a file or forcefully reload everything, the only way to have it change the environment is by restarting lorri watch
(or changing a different file).
While this may sound rather theoretical, that's actually how almost all functions in nixpkgs for developing Haskell packages work, including developPackage
, callHackage
, callCabal2nix
, and more.
I am encountering this with my project (after an adjustment). Namely it doesn't reload when I add a dependency to the .cabal
file, which is something you do a lot in Haskell.