lorri
lorri copied to clipboard
IfD workaround: manually specify files for lorri to watch
Feature description
Currently we can’t automatically find files referenced by IfD derivations (e.g. by stack2nix
, which automatically converts .cabal files to nix files).
We can add a workaround to lorri, by telling it to watch a specific set of files regardless of what it evalauates. In my case, I’d add *.cabal
to the watcher and it would pick it up again.
Target users
Projects which use IfD (basically every nontrivial business project nowadays) and have to brigde the time until lorri supports IfD
I thought we were able to trace IFD? Hmm...
Target users
heh
One option is to builtins.readFile
the input to the IFD. This works because lorri
replaces builtins.readFile
with a version that logs the file access and this log is used to determine what files to watch. So replace something like:
x = import (stack2nix ./stack.yaml);
with
x = import (builtins.deepSeq (builtins.readFile ./stack.yaml) (stack2nix ./stack.yaml));
I just found out this was true... I'd assumed there were other bugs that prevented me from modifying my package.yaml or cabal file and then things just working.
This makes a lot more sense and being able to specify *.cabal
or package.yaml
for lorri to always watch for a given project would be great.
Maybe it would make sense in the .envrc file?
I just tried @hamishmack's workaround then tried touch'ing my package.yaml and it seems lorri didn't pick up on it.
# shell.nix
{...}:
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
hsPkgs = (builtins.deepSeq (builtins.readFile ./package.yaml)) (import ./default.nix {});
in
hsPkgs.shellFor {
And I modified that file.
However... after I modified shell.nix any subsequent modifications to package.yaml were picked up.
Maybe I interrupted the lorri build that added the workaround above before it finished before my test?